<template>
  <list-layout>
    <div slot="search">
      <el-form
        :model="queryParams"
        :inline="true"
        label-position="right"
        ref="queryForm"
        v-show="showSearch"
        label-width="130px"
      >
        <!-- <el-form-item label="来料分类" prop="materialClassify">
                    <el-select v-model="queryParams.materialClassify" :placeholder="$t('public.select_holder',{select_holder: '来料分类'})" style="width:100%;" filterable clearable size="small">
                        <el-option label="采购入库" value="采购入库" />
                        <el-option label="调拨入库" value="调拨入库" />
                        <el-option label="部门/研发调用归还" value="部门/研发调用归还" />
                    </el-select>
                </el-form-item> -->
        <el-form-item
          :label="$t('inspectionManagement.plantArea')"
          prop="factoryCode"
        >
          <el-select
            v-model="queryParams.factoryCode"
            :placeholder="
              $t('public.select_holder', {
                select_holder: $t('inspectionManagement.plantArea'),
              })
            "
            style="width: 100%"
            filterable
            clearable
            size="small"
          >
            <el-option
              v-for="item in factoryList"
              :key="item.plantCode"
              :label="item.plantName"
              :value="item.plantCode"
            />
          </el-select>
        </el-form-item>

        <!-- 工厂代码  -->
        <el-form-item
          :label="$t('inspectionManagement.factoryCode')"
          prop="lot"
        >
          <el-input
            v-model="queryParams.factoryCodeLike"
            :placeholder="
              $t('public.placeholder', {
                placeholder: $t('inspectionManagement.factoryCode'),
              })
            "
            clearable
            size="small"
          />
        </el-form-item>

        <el-form-item :label="$t('inspectionManagement.inspectNo')" prop="lot">
          <el-input
            v-model="queryParams.inspectionOrder"
            :placeholder="
              $t('public.placeholder', {
                placeholder: $t('inspectionManagement.inspectNo'),
              })
            "
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item :label="$t('inventoryManagement.supplierBatchNo')" prop="lichn">
                    <el-input v-model="queryParams.lichn" :placeholder="
              $t('public.placeholder', {
                placeholder: $t('inventoryManagement.supplierBatchNo'),
              })

            " clearable size="small" @keyup.enter.native="handleQuery" />
                </el-form-item> -->
        <!--              <el-form-item :label="$t('inventoryManagement.batch')" prop="lot">
                  <el-input v-model="queryParams.lot" :placeholder="
                      $t('public.placeholder', {
                        placeholder: $t('inventoryManagement.batch'),
                      })
                    " clearable size="small" @keyup.enter.native="handleQuery" />
              </el-form-item>-->
        <el-form-item
          :label="$t('inventoryManagement.materialNo')"
          prop="materialCode"
        >
          <el-input
            v-model="queryParams.materialCode"
            :placeholder="
              $t('public.placeholder', {
                placeholder: $t('inventoryManagement.materialNo'),
              })
            "
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item
          :label="$t('inventoryManagement.materialName')"
          prop="materialName"
        >
          <el-input
            v-model="queryParams.materialName"
            :placeholder="
              $t('public.placeholder', {
                placeholder: $t('inventoryManagement.materialName'),
              })
            "
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <!--                <el-form-item :label="$t('inventoryManagement.materialMin')" prop="materialMin">
                    <el-autocomplete style="width:100%" size="small" popper-class="my-autocomplete" v-model="queryParams.materialMin" :fetch-suggestions="materialTypeRemoteMethod" placeholder="请输入内容" @select="(e)=>handleMaterialTypeSelect(e,scope)">
                        <i class="el-icon-search el-input__icon" slot="suffix">
                        </i>
                        <template slot-scope="{ item }">
                            {{ item.typeName }}
                        </template>
                    </el-autocomplete>
                    &lt;!&ndash; <el-input v-model="viewModel.materialType"  clearable size="small"  /> &ndash;&gt;
                </el-form-item>-->

        <el-form-item
          :label="$t('inventoryManagement.supplierNo')"
          prop="supplierCode"
        >
          <el-input
            v-model="queryParams.supplierCode"
            :placeholder="
              $t('public.placeholder', {
                placeholder: $t('inventoryManagement.supplierNo'),
              })
            "
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item
          :label="$t('inspectionManagement.InspectBatchNo')"
          prop="inspectionLotMark"
        >
          <el-input
            v-model="queryParams.inspectionLotMark"
            :placeholder="
              $t('public.placeholder', {
                placeholder: $t('inspectionManagement.InspectBatchNo'),
              })
            "
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>

        <el-form-item
          :label="$t('inventoryManagement.inspectionOrderstatus')"
          prop="sheetStatus"
        >
          <el-select
            v-model="queryParams.sheetStatus"
            multiple
            :placeholder="
              $t('public.select_holder', {
                select_holder: $t('inventoryManagement.inspectionOrderstatus'),
              })
            "
            clearable
            style="width: 100%"
            size="small"
          >
            <el-option key="" :label="$t('tips.all')" value="" />
            <el-option
              v-for="item in dict.type.NYIQC_SHEET_STATUS"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          :label="$t('inventoryManagement.judgmentResult')"
          prop="decideResult"
        >
          <el-select
            v-model="queryParams.decideResult"
            :placeholder="
              $t('public.select_holder', {
                select_holder: $t('inspectionManagement.judgmentResult'),
              })
            "
            style="width: 100%"
            clearable
            size="small"
          >
            <el-option
              key=""
              :label="$t('inspectionManagement.all')"
              value=""
            />
            <el-option
              key="1"
              :label="$t('inspectionManagement.qualified')"
              value="1"
            />
            <el-option
              key="0"
              :label="$t('inspectionManagement.reject')"
              value="0"
            />
          </el-select>
        </el-form-item>
        <!-- <el-form-item :label="$t('approve.approvalComments')" prop="auditResult">
                    <el-select v-model="queryParams.auditResult" :placeholder="
              $t('public.select_holder', {
                select_holder: $t('approve.approvalComments'),
              })
            " style="width: 100%" clearable size="small">
                        <el-option key="" label="全部" value="" />
                        <el-option v-for="item in dict.type.NYIQC_AUDIT_RESULT" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                    </el-select>
                </el-form-item> -->
        <el-form-item :label="$t('inspectionManagement.lot')" prop="lot">
          <el-input
            v-model="queryParams.lot"
            :placeholder="
              $t('public.placeholder', {
                placeholder: $t('inspectionManagement.lot'),
              })
            "
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item
          :label="$t('inventoryManagement.dataSource')"
          prop="dataSource"
        >
          <el-select
            v-model="queryParams.dataSource"
            :placeholder="
              $t('public.select_holder', {
                select_holder: $t('inventoryManagement.dataSource'),
              })
            "
            style="width: 100%"
            clearable
            size="small"
          >
            <el-option key="" :label="$t('tips.all')" value="" />
            <el-option key="1" :label="$t('inventoryManagement.inventoryInspection')" value="库存" />
            <el-option key="2" :label="$t('inventoryManagement.additionalInspection')" value="额外" />
            <el-option key="3" :label="$t('inventoryManagement.incomingMaterialData')" value="进料" />
          </el-select>
        </el-form-item>
        <el-form-item
          :label="$t('inventoryManagement.useDecision')"
          prop="usingDecision"
        >
          <el-select
            v-model="queryParams.usingDecision"
            :placeholder="
              $t('public.select_holder', {
                select_holder: $t('inventoryManagement.useDecision'),
              })
            "
            style="width: 100%"
            clearable
            size="small"
          >
            <el-option key="" :label="$t('tips.all')" value=""></el-option>
            <el-option
              v-for="item in dict.type.NYIQC_NCR_DECISION"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          :label="$t('inventoryManagement.isInspectionExemption')"
          prop="exempted"
        >
          <el-select
            v-model="queryParams.exempted"
            :placeholder="
              $t('public.select_holder', {
                select_holder: $t('inventoryManagement.isInspectionExemption'),
              })
            "
            style="width: 100%"
            clearable
            size="small"
          >
            <el-option key="" :label="$t('tips.all')" value=""></el-option>
            <el-option
              v-for="item in dict.type.NYIQC_EXEMPTED"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          :label="$t('inventoryManagement.preInspectionOrNot')"
          prop="checkArt"
        >
          <el-select
            v-model="queryParams.checkArt"
            :placeholder="
              $t('public.select_holder', {
                select_holder: $t('inventoryManagement.preInspectionOrNot'),
              })
            "
            style="width: 100%"
            clearable
            size="small"
          >
            <el-option key="" :label="$t('public.yes')" value="1"> </el-option>
            <el-option key="" :label="$t('public.no')" value="0"> </el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="成熟度" prop="maturity">
                    <el-select v-model="queryParams.maturity" :placeholder="
              $t('public.select_holder', {
                select_holder: '成熟度',
              })
            " style="width: 100%" clearable size="small" multiple>
                        <el-option key="1" label="1" value="1"> </el-option>
                        <el-option key="2" label="2" value="2"> </el-option>
                        <el-option key="3" label="3" value="3"> </el-option>
                        <el-option key="6" label="6" value="6"> </el-option>
                    </el-select>
                </el-form-item> -->

        <el-form-item
          :label="$t('inventoryManagement.inspectionStartTime')"
          prop="inspectionTime"
        >
          <el-date-picker
            style="width: 204px"
            v-model="queryParams.inspectionTime"
            size="small"
            type="daterange"
            value-format="yyyy-MM-dd"
            :start-placeholder="$t('public.startDate')"
            :end-placeholder="$t('public.endDate')"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          :label="$t('inventoryManagement.inspectionEndTime')"
          prop="checkoutEndTime"
        >
          <el-date-picker
            style="width: 208px"
            v-model="queryParams.checkoutEndTime"
            size="small"
            type="daterange"
            value-format="yyyy-MM-dd"
            :start-placeholder="$t('public.startDate')"
            :end-placeholder="$t('public.endDate')"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          :label="$t('inventoryManagement.reviewTime')"
          prop="reportAuditTime"
        >
          <el-date-picker
            style="width: 208px"
            v-model="queryParams.reportAuditTime"
            size="small"
            type="daterange"
            value-format="yyyy-MM-dd"
            :start-placeholder="$t('public.startDate')"
            :end-placeholder="$t('public.endDate')"
          >
          </el-date-picker>
        </el-form-item>

        <!-- isBatch -->
        <!--whether combined-->
        <el-form-item
          :label="$t('inspectionManagement.isBatch')"
          prop="isBatch"
        >
          <el-select
            v-model="queryParams.isBatch"
            :placeholder="
              $t('public.select_holder', {
                select_holder: $t('inspectionManagement.isBatch'),
              })
            "
            style="width: 100%"
            filterable
            clearable
            size="small"
          >
            <el-option key="0" :label="$t('public.no')" value="0" />
            <el-option key="1" :label="$t('public.yes')" value="1" />
          </el-select>
        </el-form-item>

        <el-form-item :label="$t('inspectionManagement.materialGrade')">
          <el-select
            v-model="queryParams.materialLevel"
            :placeholder="$t('public.selectPl')"
            style="width: 100%"
            filterable
            clearable
            size="small"
          >
            <el-option
              v-for="item in materialLevelList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('inspectionManagement.inspectionTaskType')">
          <el-select
            v-model="queryParams.inspectionTaskType"
            :placeholder="$t('public.selectPl')"
            size="small"
            clearable
          >
            <el-option
              size="mini"
              v-for="item in taskTypeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('inspectionManagement.materialTypeCode')">
          <el-select
            v-model="queryParams.materialKind"
            :placeholder="$t('public.selectPl')"
            style="width: 100%"
            filterable
            clearable
            size="small"
          >
            <el-option
              v-for="item in materialKindList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div style="display: flex; justify-content: center">
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >{{ $t("public.search") }}</el-button
        >
        <el-button
          icon="el-icon-refresh"
          class="resectBtn"
          size="mini"
          @click="resetQuery"
          >{{ $t("public.reset") }}</el-button
        >
      </div>
    </div>
    <div class="app-container">
      <div class="container-header">
        <div class="header-left">
          {{ $t("inspectionManagement.incomingInspection") }}
        </div>
        <el-button
          size="mini"
          @click="tasksvidible = true"
          style="margin-left: 20px"
        >
          {{ $t("formValidation.manuallyCreateInspectionTasks") }}
        </el-button>
        <!--raise a produce trial-->
        <el-button
          size="mini"
          @click="raiseProduceTrial"
          style="margin-left: 20px"
          v-hasPermi="['ny-iqc:incomingInspection:raiseProducingTrial']"
        >
          {{ $t("trialinvestment.raiseProduceTrial") }}
        </el-button>
        <el-button
          size="mini"
          @click="getAllChecked"
          style="margin-left: 20px"
        >
          {{ $t("formValidation.createVirtualMaterialTask") }}
        </el-button>
      </div>
      <el-row :gutter="10" style="display:flex;flex-flow:wrap;" class="mb8 btnGroup">
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:getInspectionCheck']"
            class="exportitemBtn"
            @click="handleAddIncoming"
            ><img src="@/assets/images/icons/incoming.png" alt="" />
            {{ $t("inspectionManagement.incomingInspection") }}</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini" 
            v-hasPermi="['ny-iqc:incomingInspection:getRelease']"
            class="exportitemBtn"
            @click="handlePass"
            ><img src="@/assets/images/icons/return.png" alt="" />
            {{ $t("inspectionManagement.pass") }}</el-button
          >
        </el-col>
        <!-- <el-col :span="1.5">
                    <el-button size="mini" v-hasPermi="['ny-iqc:incomingInspection:getAudit']" class="exportitemBtn" @click="handleApproval"><img src="@/assets/images/icons/approve.png" alt="" />
                        {{ $t("performanceManagement.audit") }}</el-button>
                </el-col> -->
        <!--
                <el-col :span="1.5">
                    <el-button size="mini" v-hasPermi="['ny-iqc:incomingInspection:getCollection']" class="topping-Btn" @click="handleAddtionRecording"><img src="@/assets/images/icons/additional.png" alt="" />
                        {{ $t("inspectionManagement.addtionRecording") }}</el-button>
                </el-col>
                <el-col :span="1.5">
                    <el-button size="mini" v-hasPermi="['ny-iqc:incomingInspection:print']" class="exportitemBtn" @click="handlePrinter"><img src="@/assets/images/icons/print.png" alt="" />
                        {{ $t("inspectionManagement.printer") }}</el-button>
                </el-col>-->
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:export']"
            class="exportitemBtn"
            @click="handleExport"
            ><img src="@/assets/images/icons/daochu.png" alt="" />
            {{ $t("public.export") }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:getNcrReview']"
            class="exportitemBtn"
            @click="handleNcr"
            ><img src="@/assets/images/icons/addNCR.png" alt="" />
            {{ $t("inspectionManagement.addNCRApprove") }}
          </el-button>
        </el-col>
        <!-- 取消退回 -->
        <!-- <el-col :span="1.5">
                    <el-button size="mini" v-hasPermi="['ny-iqc:incomingInspection:getReturn']" class="return-Btn" @click="handleReturn"><img src="@/assets/images/icons/back.png" alt="" />
                        {{ $t("inspectionManagement.rework") }}</el-button>
                </el-col> -->
        <!--                <el-col :span="1.5">-->
        <!--                    <el-button size="mini" v-hasPermi="['ny-iqc:incomingInspection:getInspectionCheck']" @click="oldVersionVisiable = true" class="exportitemBtn"><img src="@/assets/images/icons/incoming.png" alt="" />-->
        <!--                        {{ $t("defectIncoming.oldVersionApproval") }}</el-button>-->
        <!--                </el-col>-->
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:getReleaseApproval']"
            class="exportitemBtn"
            @click="handleReleaseOpen"
            ><img src="@/assets/images/icons/approve.png" alt="" />
            {{ $t("inspectionManagement.passAudit") }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:getReview']"
            class="exportitemBtn"
            @click="handleReview"
            ><img src="@/assets/images/icons/approve.png" alt="" />
            {{ $t("inspectionManage.transferItems") }}
          </el-button>
        </el-col>
        <!-- 分批过账 -->
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:getReview']"
            class="exportitemBtn"
            @click="showPostedQuantityDialog"
            ><img src="@/assets/images/icons/approve.png" alt="" />
            {{ $t("inspectionManage.numTransferItems") }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:handleProblem']"
            class="exportitemBtn"
            @click="handleIssues"
          >
            {{ $t("issuesManagement.initiateIssues") }}
          </el-button>
        </el-col>

        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:getReview']"
            class="exportitemBtn"
            @click="handleReturns"
          >
            {{ $t("inspectionManagement.rework") }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:getReview']"
            class="exportitemBtn"
            @click="handleInspectionAndAudit"
          >
            {{ $t("inspectionManagement.inspectionAndAudit") }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:tomes']"
            class="exportitemBtn"
            @click="handleMes"
          >
            {{ $t("inspectionManagement.inspectionResultsArePushedToMes") }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:tomes']"
            class="exportitemBtn"
            @click="preHandleMes"
          >
            {{ $t("inspectionManagement.preTestResultsPush") }}
          </el-button>
        </el-col>
        <!-- <el-col :span="1.5">
                    <el-button size="mini" class="exportitemBtn" @click="handleExportTemplate"><img src="@/assets/images/icons/daochu.png" alt="" />
                        导出检验模板</el-button>
                </el-col>
                <el-col :span="1.5">
                    <el-button size="mini" class="exportitemBtn" @click="handleExportDetail"><img src="@/assets/images/icons/daochu.png" alt="" />
                        导出详情</el-button>
                </el-col> -->
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:tomes']"
            class="exportitemBtn"
            @click="handleSalesReturn"
          >
            {{ $t("inspectionManagement.returnOfGoods") }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:tomes']"
            class="exportitemBtn"
            @click="handleReuseInspectionValue"
          >
            {{ $t("inspectionManagement.reuseTestValues") }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            size="mini"
            v-hasPermi="['ny-iqc:incomingInspection:tomes']"
            class="exportitemBtn"
            @click="openDialogSupplierNames"
          >
            修改供应商名录
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button size="mini" class="exportitemBtn" @click="exportCheckValue">
          导入设备检验值
          </el-button>
        </el-col>
        <right-toolbar
          ref="group2"
          :columns="columns"
          @callback="columnsCallback"
          v-if="false"
        ></right-toolbar>

        <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
      </el-row>
      <div class="container-table">
        <el-table
          class="table-fixed"
          :row-class-name="tableRowClassName"
          ref="multipleTable"
          :key="incomingKey"
          v-loading="loading"
          :height="tableHeight"
          border
          :data="incomingList"
          stripe
          :fit="true"
          @selection-change="handleSelectionChange"
        >
          <el-table-column
            type="selection"
            width="55"
            fixed="left"
            align="center"
            :show-overflow-tooltip="true"
          />

          <!-- 物料编码 ，物料名称，供应商名称，检验单状态，检验单号，批次号，批数量，规格图纸，是否免检，物料状态（试验、试用、试投），检验员，判定结果，使用决策，厂区，检验批号，到货日期，报检日期，单位，检验报告，COA，检验项进度，紧急放行，是否试投，是否发起问题管理，检验开始时间，检验结束时间，检验时长，供应商编号，入库结果，供应商批次号，采购订单号，是否为合格供应商 -->
          <!-- 到货日期 -->
          <el-table-column
            fixed="left"
            :label="$t('inspectionManagement.cputime')"
            sortable
            :min-width="getColumnWidth('cputime')"
            align="center"
            prop="cputime"
            :show-overflow-tooltip="true"
          />
          <!-- 物料编号 -->
          <el-table-column
            fixed="left"
            :label="$t('inventoryManagement.materialNo')"
            sortable
            :min-width="getColumnWidth('materialCode')"
            align="center"
            prop="materialCode"
            :show-overflow-tooltip="true"
          />
          <!-- 物料名称 -->
          <el-table-column
            fixed="left"
            :label="$t('inventoryManagement.materialName')"
            sortable
            :min-width="getColumnWidth('materialName')"
            align="center"
            prop="materialName"
            :show-overflow-tooltip="true"
          />
          <!-- 供应商名称 -->
          <el-table-column
            :label="$t('inventoryManagement.supplierName')"
            sortable
            :min-width="getColumnWidth('supplierName')"
            align="center"
            prop="supplierName"
            :show-overflow-tooltip="true"
          />
          <!-- 批数量 -->
          <el-table-column
            :label="$t('inventoryManagement.batchQuantity')"
            sortable
            align="center"
            min-width="100"
            prop="batchAmount"
            :show-overflow-tooltip="true"
          />
          <!-- 检验单状态 -->
          <el-table-column
            :label="$t('inventoryManagement.inspectionOrderstatus')"
            sortable
            align="center"
            prop="sheetStatus"
            width="110px"
          >
            <template slot-scope="scope">
              <div :class="sheetColorChange(scope.row)">
                {{ formatOrderStatus(scope.row.sheetStatus) }}
              </div>
            </template>
          </el-table-column>

          <!-- 审核状态 -->
          <el-table-column
            :label="$t('inspectionManagement.approvalStatus')"
            sortable
            align="center"
            prop="reportAuditStatus"
            width="110px"
          >
            <template slot-scope="scope">
              <div :class="approvalStatusColorChange(scope.row)">
                {{ formatApprovalStatus(scope.row.reportAuditStatus) }}
              </div>
            </template>
          </el-table-column>
          <!-- 检验任务类型 -->
          <el-table-column
            :label="$t('inspectionManagement.inspectionTaskType')"
            sortable
            align="center"
            prop="inspectionTaskType"
            width="110px"
          >
            <template slot-scope="scope">
              <div>
                {{
                  scope.row.inspectionTaskType == null
                    ? ""
                    : scope.row.inspectionTaskType == 1
                    ? $t("inspectionManagement.incomingInspection")
                    : $t("inventoryManagement.inventoryInspection")
                }}
              </div>
            </template>
          </el-table-column>
          <!-- 审核人 -->
          <el-table-column
            :label="$t('inspectionManagement.reviewer')"
            sortable
            align="center"
            minWidth="140"
            prop="reportAuditName"
            :show-overflow-tooltip="true"
          />
          <!-- 审核时间 -->
          <el-table-column
            :label="$t('inventoryManagement.reviewTime')"
            sortable
            align="center"
            minWidth="140"
            prop="reportAuditTime"
            :show-overflow-tooltip="true"
          />
         
          <!-- 当前策略 -->
          <el-table-column
            :label="$t('transferRules.currentTactics')"
            sortable
            align="center"
            width="110px"
          >
            <template slot-scope="scope">
              <div>{{ formatTactics(scope.row.currentTactics) }}</div>
            </template>
          </el-table-column>
          <!-- 判定结果 -->
          <el-table-column
            :label="$t('inventoryManagement.judgmentResult')"
            sortable
            v-if="columns[13].visible"
            min-width="120"
            align="center"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <!-- <div class="greenTag" v-if="scope.row.decideResult == '1'">合格</div>
                <div class="redTag" v-if="scope.row.decideResult == '0'">不合格</div> -->
              <div class="greenTag" v-if="scope.row.decideResult == '1'">
                {{ $t("inventoryManagement.qualified") }}
              </div>
              <div class="redTag" v-if="scope.row.decideResult == '0'">
                {{ $t("inventoryManagement.unqualified") }}
              </div>
            </template>
          </el-table-column>
          <!-- 是否免检 -->
          <el-table-column
            :label="$t('inventoryManagement.skipBatchExemptionFromInspection')"
            sortable
            v-if="columns[24].visible"
            align="center"
            prop="exempted"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <div class="action-wrap">
                <span v-if="parseInt(scope.row.exempted) === 0" class="labelY"
                  >{{ $t('public.no') }}</span
                >
                <span v-if="parseInt(scope.row.exempted) === 1" class="labelY"
                  >{{ $t('public.yes') }}</span
                >
                <span v-if="parseInt(scope.row.exempted) === 2" class="labelB"
                  >{{ $t('inspectionManagement.Inapproval') }}</span
                >
              </div>
            </template>
          </el-table-column>
          <!-- 批次号 -->
          <el-table-column
            :label="$t('inspectionManagement.lichn')"
            sortable
            v-if="columns[25].visible"
            align="center"
            prop="lichn"
            minWidth="160"
            :show-overflow-tooltip="true"
          />
          <!-- 检验单号 -->
          <el-table-column
            :label="$t('inspectionManagement.inspectNo')"
            sortable
            v-if="columns[1].visible"
            align="center"
            minWidth="140"
            prop="inspectionOrder"
            :show-overflow-tooltip="true"
          />
          <!-- 过账数量 -->
          <el-table-column
            :label="$t('inventoryManagement.postedQuantity')"
            sortable
            v-if="columns[11].visible"
            align="center"
            min-width="100"
            prop="accountAmount"
            :show-overflow-tooltip="true"
          />
          <!-- 规格图纸 -->
          <!-- <el-table-column :label="$t('inspectionManagement.sizeDrawing')" sortable align="center"
                             min-width="100" prop="sizeDrawing" :show-overflow-tooltip="true"/> -->
          <!-- 行业标准 -->
          <!-- <el-table-column :label="$t('inspectionManagement.industryStandards')" sortable align="center"
                             min-width="100" prop="normt" :show-overflow-tooltip="true"/> -->
          <!-- 是否前置检验 -->
          <el-table-column
            :label="$t('inventoryManagement.preInspectionOrNot')"
            sortable
            v-if="columns[24].visible"
            align="center"
            prop="exempted"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <div class="action-wrap">
                <span v-if="scope.row.art !== '03'" class="labelB">{{
                  $t("public.no")
                }}</span>
                <span v-if="scope.row.art === '03'" class="labelY">{{
                  $t("public.yes")
                }}</span>
              </div>
            </template>
          </el-table-column>
          <!-- 是否为冲销任务 -->
          <el-table-column
            :label="$t('inventoryManagement.IsReversalTask')"
            sortable
            v-if="columns[24].visible"
            align="center"
            prop="coverStatusVal"
            :show-overflow-tooltip="true"
          />
          <!-- 物料状态（试验、试用、试投） 未知 -->
          <el-table-column
            :label="$t('material.materialStatus')"
            sortable
            v-if="columns[14].visible"
            align="center"
            prop="materialTaskStatusVal"
            minWidth="100"
            :show-overflow-tooltip="true"
          />
          <!-- 检验员 -->
          <el-table-column
            :label="$t('inspectionManagement.inspector')"
            sortable
            v-if="columns[14].visible"
            align="center"
            prop="tionInspectorName"
            minWidth="100"
            :show-overflow-tooltip="true"
          />
          <!-- 使用决策 结束 -->
          <el-table-column
            :label="$t('inventoryManagement.useDecision')"
            sortable
            v-if="columns[20].visible"
            align="center"
            width="100px"
            prop="usingDecision"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <span
                v-if="scope.row.usingDecision"
                :class="formatUsingDecisionTag(scope.row.usingDecision)"
                >{{ formatUsingDecision(scope.row.usingDecision) }}</span
              >
            </template>
          </el-table-column>
          <!-- 厂区 -->
          <el-table-column
            :label="$t('inventoryManagement.factory')"
            sortable
            v-if="columns[0].visible"
            align="center"
            prop="factoryName"
            min-width="180"
            :show-overflow-tooltip="true"
          />
          <!-- 检验批号 -->
          <el-table-column
            :label="$t('inventoryManagement.inspectionBatchNo')"
            sortable
            v-if="columns[23].visible"
            align="center"
            prop="inspectionLotMark"
            minWidth="160"
            :show-overflow-tooltip="true"
          />

          <!-- 报检日期 -->
          <el-table-column
            :label="$t('inspectionManagement.deliveryDate')"
            sortable
            v-if="columns[1].visible"
            align="center"
            minWidth="140"
            prop="deliveryDate"
            :show-overflow-tooltip="true"
          />
          <!-- 单位  -->
          <el-table-column
            :label="$t('inventoryManagement.unit')"
            align="center"
            prop="mengeneinh"
            min-width="100"
            :show-overflow-tooltip="true"
          />
          <!-- 检验报告 -->
          <el-table-column
            :label="$t('inspectionManagement.COAReport')"
            sortable
            v-if="columns[1].visible"
            align="center"
            minWidth="170"
            prop="inspectionOrder"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <el-button type="text" @click="handleDialogCoa(scope.row)">
                选择报告
              </el-button>
              <!-- <el-button type="text" @click="handleExportCoa(scope.row)">
                {{ $t("inspectionManagement.COAReportDownload") }}
              </el-button>
              <el-button type="text" @click="handleENCOAExport(scope.row)">
                {{ $t("inspectionManagement.ENCOAReportDownload") }}
              </el-button> -->
            </template>
          </el-table-column>
          <!-- COA -->
          <el-table-column
            :label="$t('inspectionManagement.COA')"
            sortable
            v-if="columns[42].visible"
            min-width="80"
            align="center"
            prop="inspectionCoa"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <span v-if="scope.row.inspectionCoa == 0">OK</span>
              <span v-if="scope.row.inspectionCoa == 1">NG</span>
              <span v-if="scope.row.inspectionCoa == null">NA</span>
            </template>
          </el-table-column>
          <!-- 检验项进度 -->
          <el-table-column
            :label="$t('inspectionManagement.inspectProgress')"
            align="center"
            prop="itemProgress"
            sortable
            v-if="columns[5].visible"
            min-width="120"
            :show-overflow-tooltip="true"
          />
          <!-- 是否紧急放行 -->
          <el-table-column
            :label="$t('inspectionManagement.isPass')"
            sortable
            v-if="columns[27].visible"
            align="center"
            min-width="100"
            prop="release"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <div class="action-wrap">
                <span class="labelY" v-if="parseInt(scope.row.release) > 0"
                  >{{ $t('public.yes') }}</span
                >
                <span class="labelN" v-if="parseInt(scope.row.release) === 0"
                  >{{ $t('public.no')}}</span
                >
              </div>
            </template>
          </el-table-column>
          <!-- 是否试投 -->
          <el-table-column
            :label="$t('inspectionManagement.whetherTrial')"
            sortable
            v-if="columns[40].visible"
            align="center"
            min-width="100"
            prop="whetherTrial"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              {{ scope.row.whetherTrial == 1 ? $t('public.yes') : $t('public.no') }}
            </template>
          </el-table-column>
          <!-- 是否发起问题管理 -->
          <el-table-column
            :label="$t('issuesManagement.initiateIssues')"
            align="center"
            prop="triggerQpms"
            minWidth="160"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.triggerQpms == "1" ? $t('public.yes') : $t('public.no') }}</span>
            </template>
          </el-table-column>
          <!-- 检验开始时间 -->
          <el-table-column
            :label="$t('inspectionManagement.inspectionStartTime')"
            sortable
            v-if="columns[4].visible"
            min-width="150"
            align="center"
            prop="inspectionStartTime"
            :show-overflow-tooltip="true"
          />
          <!-- 检验完成日期 -->
          <el-table-column
            :label="$t('inspectionManagement.inspectionEndtTime')"
            sortable
            v-if="columns[21].visible"
            min-width="125"
            align="center"
            prop="inspectionEndTime"
            :show-overflow-tooltip="true"
          />
          <!-- 检验工时 -->
          <el-table-column
            :label="$t('inspectionManagement.inspectionDuration')"
            sortable
            v-if="columns[29].visible"
            align="center"
            min-width="100"
            prop="inspectionDuration"
            :show-overflow-tooltip="true"
          />
           <!-- 是否检验超时 -->
           <el-table-column
            :label="$t('inventoryManagement.whetherToVerifyTimeout')"
            sortable
            align="center"
            minWidth="140"
          >
            <template slot-scope="scope">
              <div>
                {{
                  scope.row.isOverTime !== null
                    ? scope.row.isOverTime == 0
                      ? $t("public.no")
                      : $t("public.yes")
                    : ""
                }}
              </div>
            </template>
          </el-table-column>
          <!-- 供应商编号 -->
          <el-table-column
            :label="$t('inventoryManagement.supplierNo')"
            sortable
            v-if="columns[10].visible"
            align="center"
            prop="supplierCode"
            min-width="210"
            :show-overflow-tooltip="true"
          />
          <!-- 入库结果 -->
          <el-table-column
            :label="$t('inspectionManagement.warehousingResults')"
            align="center"
            prop="storageFailure"
            min-width="140"
            :show-overflow-tooltip="true"
          />
          <!-- 采购订单号 -->
          <el-table-column
            :label="$t('inspectionManagement.purchaseOrderNo')"
            sortable
            v-if="columns[32].visible"
            align="center"
            prop="ebeln"
            minWidth="140"
            :show-overflow-tooltip="true"
          />
          <!-- 采购订单类型 -->
          <el-table-column
            :label="$t('inspectionManagement.purchasingOrderType')"
            sortable
            v-if="columns[32].visible"
            align="center"
            prop="batxt"
            minWidth="140"
            :show-overflow-tooltip="true"
          />
          <!-- 是否合批-->
          <el-table-column
            :label="$t('inspectionManagement.isBatch')"
            sortable
            v-if="columns[39].visible"
            align="center"
            min-width="100"
            prop="isBatch"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              {{ scope.row.isBatch == 1 ? $t('public.yes') : $t('public.no') }}
            </template>
          </el-table-column>
          <!-- 行业标准 -->
          <el-table-column
            :label="$t('inspectionManagement.industryStandards')"
            sortable
            v-if="columns[38].visible"
            align="center"
            min-width="100"
            prop="normt"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <!-- 调拨状态 -->
          <el-table-column
            label="调拨状态"
            sortable
            align="center"
            minWidth="100"
            :show-overflow-tooltip="true"
          >
            <template slot-scope="scope">
              <span>{{ bsartTXT(scope.row.bsart) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            :label="$t('public.opera')"
            fixed="right"
            align="center"
            width="140"
          >
            <template slot-scope="scope">
              <div class="action-wrap">
                <!-- <table-body-btn type="gwedit" v-if="scope.row.usingDecision !== '3'&&(scope.row.sheetStatus==='2'||scope.row.sheetStatus==='4')" v-hasPermi="['ny-iqc:nlenr:updateDecisionJieshu']" name="箱号" @click.native="handleSelectUse(scope.row)" /> -->
                <table-body-btn
                  type="gwedit"
                  v-if="scope.row.usingDecision === '2'"
                  name="挑选"
                  @click.native="handleReFixed(scope.row)"
                />
                <table-body-btn
                  type="gwview"
                  :name="$t('home.view')"
                  @click.native="handleView(scope)"
                  v-hasPermi="['ny-iqc:incomingInspection:getInfo']"
                />
                <!-- <table-body-btn type="gwviewImport" name="报表" @click.native="handlePrinterView(scope)" /> -->
              </div>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
          layout="total, sizes, prev, pager, next, jumper"
        />
      </div>

      <!-- 发起NCR -->
      <el-dialog
        :title="$t('inspectionManagement.addNCRApprove')"
        :visible.sync="addInspection"
        center
        top="14vh"
        width="1200px"
        append-to-body
        :fullscreen="fullscreen"
      >
        <el-form
          :model="editModel"
          ref="queryForm"
          label-width="90px"
          label-position="top"
        >
          <el-row :gutter="24" class="mb8">
            <!-- <el-col :span="24">
                            <el-form-item :label="$t('inspectionManagement.isContain')">
                                <el-radio-group v-model="ncrModel.whetherStem" disabled>
                                    <el-radio label="2">{{ $t("public.no") }}</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col> -->
            <el-col :span="24" style="margin-bottom: 20px">
              <el-table
                stripe
                ref="ncrTable"
                v-loading="loading"
                :data="ncrModel.voList"
                :key="ncrRefresh"
              >
                <el-table-column
                  :label="$t('inventoryManagement.supplierBatchNo')"
                  align="center"
                  prop="lichn"
                  min-width="160"
                />
                <el-table-column
                  :label="$t('inventoryManagement.supplierNo')"
                  align="center"
                  prop="supplierCode"
                  min-width="120"
                  :show-overflow-tooltip="true"
                />
                <!-- <el-table-column label="【SAP】成熟度" align="center" prop="maturity" min-width="80" :show-overflow-tooltip="true" /> -->
                <el-table-column
                  :label="$t('inventoryManagement.materialNo')"
                  align="center"
                  prop="materialCode"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  :label="$t('inventoryManagement.materialName')"
                  show-overflow-tooltip
                  align="center"
                  prop="materialName"
                />
                <el-table-column
                  :label="$t('inventoryManagement.materialType')"
                  align="center"
                  prop="materialType"
                  min-width="140"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  :label="$t('inventoryManagement.factory')"
                  align="center"
                  prop="factoryName"
                  min-width="140"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  :label="$t('inspectionManagement.sapBatch')"
                  align="center"
                  prop="lot"
                  min-width="140"
                  :show-overflow-tooltip="true"
                />

                <el-table-column
                  :label="$t('inspectionManagement.incomingQuantity')"
                  align="center"
                  prop="batchAmount"
                  min-width="140"
                  :show-overflow-tooltip="true"
                />
                <!-- <el-table-column label="不合格数量" align="center" fixed="right" min-width="120" :show-overflow-tooltip="true">
                                    <template slot-scope="scope">
                                        <div class="action-wrap" style="margin-top: 5px">
                                            <el-input-number @input="if(scope.row.onlineUnqualified<0||scope.row.onlineUnqualified==null||scope.row.onlineUnqualified==undefined)scope.row.onlineUnqualified=0" min=0 :controls="false" v-model="scope.row.onlineUnqualified" style="width:100%" size="small" />
                                        </div>
                                    </template>
                                </el-table-column> -->
                <el-table-column
                  :label="$t('inventoryManagement.unit')"
                  align="center"
                  fixed="right"
                  prop="mengeneinh"
                  min-width="100"
                  :show-overflow-tooltip="true"
                />

                <el-table-column
                  :label="$t('mrbForm.flawChoice')"
                  align="center"
                  fixed="right"
                  min-width="260"
                  :show-overflow-tooltip="true"
                >
                  <template slot-scope="scope">
                    <div
                      class="action-wrap"
                      :key="index"
                      v-for="(item, index) in scope.row.flawList"
                      style="margin-top: 5px"
                    >
                      <el-select
                        v-model="item.minFlawName"
                        style="width: 40%"
                        placeholder="缺陷选择"
                        @visible-change="
                          (e) => showSelect(e, scope.row.materialType)
                        "
                        clearable
                        size="small"
                      >
                        <el-option
                          v-for="flaw in minFlawOptions"
                          @click.native="changeFlaw(flaw, scope, index)"
                          :key="flaw.id"
                          :label="flaw.minFlawName"
                          :value="flaw.minFlawName"
                        />
                      </el-select>
                      <el-input
                        style="width: 40%; margin-left: 5px"
                        v-model="item.minFlawNr"
                        size="small"
                      />
                      <table-body-btn
                        type="add"
                        style="margin-left: 5px"
                        @click.native="addFlaw(scope)"
                      />
                      <table-body-btn
                        type="delete"
                        @click.native="deleteFlaw(scope, index)"
                      />
                    </div>
                    <!-- <el-select v-model="scope.row.minFlawName" :placeholder="$t('public.select_holder',{select_holder: '缺陷选择'})" filterable size="small">
                                            <el-option v-for="item in minFlawOptions" :key="item.id" :label="item.minFlawName" :value="item.minFlawName" />
                                        </el-select> -->
                  </template>
                </el-table-column>
                <!-- <el-table-column fixed="right" :label="
                    $t('inspectionManagement.containmentLocation') +
                    '/' +
                    $t('inspectionManagement.containmentQuantity')
                  " v-if="ncrModel.whetherStem === '1'" align="center" prop="stemVoList" min-width="300">
                                    <template slot-scope="scope">
                                        <div class="action-wrap" :key="index" v-for="(item, index) in scope.row.stemVoList" style="margin-top: 5px">
                                            <el-select v-model="item.stemName" style="width: 40%" :placeholder="
                          $t('inspectionManagement.containmentLocation')
                        " clearable @change="(e) => changeStem(e, scope, index)" size="small">
                                                <el-option v-for="item in stemList" :key="item.stemLocationName" :label="item.stemLocationName" :value="item.stemLocationName" />
                                            </el-select>
                                            <el-input @input="(e) => changeStemNumber(e, scope, index)" style="width: 40%; margin-left: 5px" v-model="item.stemNumber" size="small" />
                                            <table-body-btn type="add" style="margin-left: 5px" @click.native="addStem(scope)" />
                                            <table-body-btn type="delete" @click.native="deleteStem(scope, index)" />
                                        </div>
                                    </template>
                                </el-table-column> -->
              </el-table>
            </el-col>
            <!-- <el-col :span="24">
                            <el-form-item :label="$t('inspectionManagement.problemFinderOrder')">
                                {{ncrModel.ncrType}}
                            </el-form-item>
                        </el-col> -->
            <!-- <el-col :span="8">
                            <el-form-item :label="$t('inspectionManagement.shift')">
                                <el-select v-model="ncrModel.shift" :placeholder="
                    $t('public.select_holder', {
                      select_holder: $t('inspectionManagement.shift'),
                    })
                  " style="width: 185px" clearable size="small">
                                    <el-option key="白班" label="白班" value="白班" />
                                    <el-option key="晚班" label="晚班" value="晚班" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('inspectionManagement.initiatingPlant')">
                                <el-select v-model="ncrModel.initiatingPlant" :placeholder="
                    $t('public.select_holder', {
                      select_holder: $t('inspectionManagement.initiatingPlant'),
                    })
                  " clearable @change="factoryChange" size="small" style="width: 185px">
                                    <el-option v-for="item in factoryList" :key="item.factoryName" :label="item.factoryName" :value="item.factoryName" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item :label="$t('inspectionManagement.materialClassQ')">
                                <el-select v-model="ncrModel.qclass" :placeholder="
                    $t('public.select_holder', {
                      select_holder: $t('inspectionManagement.materialClassQ'),
                    })
                  " clearable size="small" style="width: 185px">
                                    <el-option v-for="dict in dict.type.NYIQC_NCR_QCLASS" :key="dict.label" :label="dict.label" :value="dict.value" />
                                </el-select>
                            </el-form-item>
                        </el-col> -->
            <el-col :span="24">
              <!-- <el-form-item :label="$t('inspectionManagement.specificationsStandards')">
                                <el-input type="textarea" style="width:100%" :rows="8" v-model="ncrModel.specification" size="small" :placeholder="$t('public.inputPl')" @keyup.enter.native="handleQuery" />
                            </el-form-item>
                            <el-form-item label=" ">
                                <file-upload v-model="ncrModel.file1" @change="imgFileChange1" bizType=SPECIFICATION_UPLOAD></file-upload>
                            </el-form-item> -->
              <el-form-item :label="$t('basicData.description')">
                <el-input
                  type="textarea"
                  style="width: 100%"
                  :rows="8"
                  v-model="ncrModel.flawDescription"
                  size="small"
                  :placeholder="$t('public.inputPl')"
                  @keyup.enter.native="handleQuery"
                />
              </el-form-item>
              <el-form-item label=" ">
                <file-upload
                  v-model="ncrModel.file2"
                  @change="imgFileChange2"
                  bizType="FLAW_UPLOAD"
                ></file-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>

        <div slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            @click="submitNcrForm"
            icon="el-icon-check"
            size="small"
            >{{ $t("public.define") }}
          </el-button>
        </div>
      </el-dialog>
      <!-- 返工 -->
      <el-dialog
        title="挑选"
        :visible.sync="returnInspection"
        center
        top="14vh"
        width="1200px"
        append-to-body
        :fullscreen="fullscreen"
      >
        <el-form ref="returnForm" label-width="90px" label-position="right">
          <el-row :gutter="24" class="mb8">
            <el-col :span="24" style="margin-bottom: 20px">
              <el-table
                stripe
                ref="ncrTable"
                v-loading="loading"
                :key="returnKey"
                :data="returnList"
              >
                <el-table-column
                  label="检验批号"
                  align="center"
                  prop="inspectionLotMark"
                  min-width="140"
                  :show-overflow-tooltip="true"
                />

                <el-table-column
                  label="批数量"
                  align="center"
                  prop="batchAmount"
                  min-width="140"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  label="接收数量"
                  align="center"
                  min-width="120"
                  :show-overflow-tooltip="true"
                >
                  <template slot-scope="scope">
                    <div class="action-wrap" style="margin-top: 5px">
                      <el-input
                        min="0"
                        :controls="false"
                        type="number"
                        v-model="scope.row.acceptAmount"
                        @input="
                          (val) => acceptChange(val, scope.row, scope.$index)
                        "
                        style="width: 100%"
                        size="small"
                      />
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  label="退货数量"
                  align="center"
                  min-width="120"
                  :show-overflow-tooltip="true"
                >
                  <template slot-scope="scope">
                    <div class="action-wrap" style="margin-top: 5px">
                      <el-input
                        min="0"
                        :controls="false"
                        type="number"
                        v-model="scope.row.returnAmount"
                        @input="
                          (val) => returnChange(val, scope.row, scope.$index)
                        "
                        style="width: 100%"
                        size="small"
                      />
                    </div>
                  </template>
                </el-table-column>

                <el-table-column
                  label="入库结果"
                  align="center"
                  prop="storageFailure"
                  min-width="140"
                  :show-overflow-tooltip="true"
                />
                <el-table-column
                  :label="$t('public.opera')"
                  align="center"
                  width="80"
                  :show-overflow-tooltip="true"
                >
                  <template slot-scope="scope">
                    <div class="action-wrap">
                      <a
                        @click="handleSave(scope.row, scope.$index)"
                        style="cursor: pointer; color: #409eff; font-size: 12px"
                      >
                        {{ scope.row.storageRetrial === "2" ? "反审" : "入库" }}
                      </a>
                      <!-- <table-body-btn type="template" v-hasPermi="['ny-iqc:nlenr:updateDecisionJieshu']" name="入库" @click.native="handleSave(scope.row)" /> -->
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
          </el-row>
        </el-form>

        <!-- <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="submitNcrForm" icon="el-icon-check" size="small">{{ $t("public.define") }}</el-button>
                </div> -->
      </el-dialog>
      <el-dialog
        :title="$t('mrbForm.initiateMRB')"
        :visible.sync="approvalOpen"
        center
        top="14vh"
        width="1000px"
        append-to-body
        :fullscreen="fullscreen"
      >
        <el-form
          :model="approvalModel"
          size="small"
          label-suffix=":"
          ref="detailForm"
          label-width="88px"
        >
          <el-row gutter="15">
            <el-col :span="6">
              <el-form-item
                :label="$t('inventoryManagement.materialName')"
                prop="materialName"
              >
                <el-input
                  v-model="approvalModel.materialName"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                :label="$t('inventoryManagement.materialNo')"
                prop="materialCode"
              >
                <el-input
                  v-model="approvalModel.materialCode"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                :label="$t('inventoryManagement.supplierNo')"
                prop="supplierCode"
              >
                <el-input
                  v-model="approvalModel.supplierCode"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                :label="$t('inspectionManagement.sapBatch')"
                prop="inspectionLotMark"
              >
                <el-input
                  v-model="approvalModel.inspectionLotMark"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>

            <el-col :span="6">
              <el-form-item label="特采时间" prop="specialTime">
                <el-date-picker
                  v-model="approvalModel.specialTime"
                  type="date"
                  value-format="yyyy-MM-dd"
                  :picker-options="expireTimeOptions"
                  @change="handleExpireTime"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                :label="$t('mrbForm.acceptDeviationNum')"
                prop="batchAmount"
              >
                <el-input
                  v-model="approvalModel.batchAmount"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                :label="$t('inventoryManagement.unit')"
                prop="mengeneinh"
              >
                <el-input
                  v-model="approvalModel.mengeneinh"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                :label="$t('mrbForm.expectedDate')"
                prop="expectedDate"
              >
                <el-date-picker
                  v-model="approvalModel.expectedDate"
                  type="date"
                  value-format="yyyy-MM-dd"
                  :picker-options="expireTimeOptions"
                  @change="handleExpireTime"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('mrbForm.unusualContent')" prop="lot">
                <el-input
                  size="small"
                  type="textarea"
                  disabled
                  :autosize="{ minRows: 3, maxRows: 4 }"
                  v-model="auditCause"
                  maxlength="1000"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item :label="$t('mrbForm.auditCause')" prop="auditCause">
                <el-input
                  size="small"
                  type="textarea"
                  :autosize="{ minRows: 3, maxRows: 4 }"
                  v-model="approvalModel.auditCause"
                  maxlength="1000"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item
                :label="$t('mrbForm.specification')"
                prop="specification"
              >
                <el-input
                  size="small"
                  type="textarea"
                  :autosize="{ minRows: 3, maxRows: 4 }"
                  v-model="approvalModel.specification"
                  maxlength="1000"
                >
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row gutter="15">
            <!-- <el-col :span="8">
                            <el-form-item label="申请单位" prop="lot">
                                <el-input v-model="approvalModel.lot" clearable disabled size="small" />
                            </el-form-item>
                        </el-col> -->
            <el-col :span="12">
              <el-form-item
                :label="$t('inventoryManagement.purchaseDept')"
                prop="deptName"
              >
                <el-input size="small" v-model="deptName" disabled />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item
                :label="$t('inventoryManagement.purchaser')"
                prop="name"
              >
                <el-input size="small" v-model="name" disabled />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row gutter="15">
            <el-col :span="24">
              <el-form-item
                :label="$t('inspectionManagement.judgmentResult')"
                prop="lot"
              >
                <el-radio-group
                  v-model="approvalModel.auditResult"
                  class="smallRadio"
                >
                  <el-radio label="0"> 空 </el-radio>
                  <el-radio
                    :key="item.value"
                    :label="item.value"
                    v-for="item in dict.type.NYIQC_AUDIT_RESULT"
                    >{{ item.label }}
                  </el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            @click="submitApproval"
            :loading="loading"
            icon="el-icon-document"
            size="small"
            >{{ $t("public.save") }}
          </el-button>
        </div>
      </el-dialog>
      <!-- 审批 -->
      <!-- <el-dialog :title="$t('performanceManagement.audit')" :visible.sync="approvalOpen" center top="14vh" width="700px" append-to-body :fullscreen="fullscreen">
                <el-form :model="approvalModel" ref="approvalForm" label-position="top">
                    <el-form-item :label="$t('performanceManagement.auditOpinion')" prop="auditResult">
                        <el-radio-group v-model="approvalModel.auditResult" class="smallRadio">
                            <el-radio label="0">
                                空
                            </el-radio>
                            <el-radio :key="item.value" :label="item.value" v-for="item in dict.type.NYIQC_AUDIT_RESULT">{{
                item.label}}</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="审核人" prop="name">
                        <el-input size="small" v-model="name" disabled>
                        </el-input>
                    </el-form-item>
                    <el-form-item :label="$t('inspectionManagement.approvalReason')" prop="auditCause">
                        <el-input size="small" type="textarea" :autosize="{ minRows: 5, maxRows: 6 }" v-model="approvalModel.auditCause" maxlength="1000">
                        </el-input>
                    </el-form-item>
                    <el-form-item :label="$t('inventoryManagement.uploadAttachments')" prop="uploadAttachments" style="width:100%">
                        <file-upload v-model="uploadAttachments" :otherList="otherList" ref="incomingFiles" :bizId="ids[0]" @change="(fileList)=>incomingFileChange(fileList)"></file-upload>
                    </el-form-item>
                    <el-form-item :label="$t('inventoryManagement.notifier')" prop="auditNotifier">
                        <select-user-dialog :multiple="true" v-model="approvalModel.auditNotifier" @callback="(row) => userDataCallback(row)" />
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="submitApproval" icon="el-icon-check" size="small">{{ $t("public.define") }}</el-button>
                </div>
            </el-dialog> -->
      <!-- 打印 -->
      <el-dialog
        :title="$t('inspectionManagement.printer')"
        :visible.sync="printerOpen"
        center
        top="34vh"
        width="500px"
        append-to-body
        :fullscreen="fullscreen"
      >
        <el-form
          :model="queryParams"
          ref="printerForm"
          v-model="printerForm"
          label-position="top"
        >
          <el-form-item
            :label="$t('inspectionManagement.printerNum')"
            prop="auditor"
          >
            <el-input
              v-model="queryParams.printerNum"
              min="1"
              type="number"
              :placeholder="
                $t('public.placeholder', {
                  placeholder: $t('inspectionManagement.printerNum'),
                })
              "
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            @click="submitPrinter"
            icon="el-icon-check"
            size="small"
            >{{ $t("public.define") }}
          </el-button>
        </div>
      </el-dialog>

      <el-drawer
        :with-header="false"
        :visible.sync="drawer"
        size="50%"
        :direction="direction"
        :before-close="handleClose"
      >
        <div class="app-container">
          <div class="container-header">
            <div class="header-left">
              {{ $t("inventoryManagement.editInspection") }}
            </div>
          </div>
          <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
              <el-button
                type="primary"
                icon="el-icon-plus"
                size="mini"
                @click="handleAdd"
                >{{ $t("inventoryManagement.addInspection") }}
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                type="primary"
                icon="el-icon-edit-outline"
                size="mini"
                @click="handleApproval"
                >{{ $t("inventoryManagement.approval") }}
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button type="primary" icon="el-icon-upload2" size="mini"
                >{{ $t("inventoryManagement.topping") }}
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button type="primary" icon="el-icon-upload" size="mini"
                >{{ $t("inventoryManagement.export") }}
              </el-button>
            </el-col>
          </el-row>
          <div class="container-table">
            <el-table
              stripe
              v-loading="loading"
              :data="incomingList"
              @selection-change="handleSelectionChange"
            >
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column
                :label="$t('inventoryManagement.inspectionBatchNo')"
                align="center"
                prop="noticeId"
                min-width="140"
              />
              <el-table-column
                :label="$t('inventoryManagement.unit')"
                align="center"
                prop="noticeTitle"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                :label="$t('inventoryManagement.recheckSheet')"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template slot-scope="scope">
                  <span>{{
                    scope.row.noticeType == "1"
                      ? $t("message.notice")
                      : $t("message.announcement")
                  }}</span>
                </template>
              </el-table-column>
              <el-table-column
                :label="$t('inventoryManagement.approvalTime')"
                align="center"
                prop="hasRead"
              >
                <template slot-scope="scope">
                  {{
                    scope.row.hasRead == 0
                      ? $t("message.unread")
                      : $t("message.read")
                  }}
                </template>
              </el-table-column>
              <el-table-column
                :label="$t('inventoryManagement.rejectReason')"
                align="center"
                prop="rejectReason"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                :label="$t('inventoryManagement.approvalStatus')"
                align="center"
                prop="approvalStatus"
                :show-overflow-tooltip="true"
              />
              <el-table-column
                :label="$t('inventoryManagement.inspectionOrderstatus')"
                align="center"
                prop="inspectionOrderstatus"
                min-width="120"
                :show-overflow-tooltip="true"
              />
            </el-table>
          </div>
        </div>
        <div class="drawer-footer">
          <el-button
            icon="el-icon-close"
            size="mini"
            @click="drawerClose"
            class="drawer-close"
            >{{ $t("public.close") }}
          </el-button>
        </div>
      </el-drawer>
      <!-- 旧版本审批 -->
      <old-version-main
        :visible.sync="oldVersionVisiable"
        v-model="form"
      ></old-version-main>
      <printer-dialog
        :visible.sync="printerVisible"
        :previewModel="previewModel"
      />
      <!-- 审批 -->
      <el-dialog
        :title="$t('inspectionManagement.passAudit')"
        :visible.sync="releaseOpen"
        center
        top="14vh"
        width="500px"
        append-to-body
        :fullscreen="fullscreen"
      >
        <el-form :model="releaseForm" ref="releaseForm" label-position="top">
          <el-form-item
            :label="$t('inventoryManagement.isPassApproval')"
            prop="release"
          >
            <el-radio-group v-model="releaseForm.release">
              <el-radio label="1"
                >{{ $t("inventoryManagement.pass") }}
              </el-radio>
              <el-radio label="0"
                >{{ $t("inventoryManagement.reject") }}
              </el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            @click="submitRelease"
            icon="el-icon-check"
            size="small"
            >{{ $t("public.define") }}
          </el-button>
        </div>
      </el-dialog>

      <!-- 人工创建检验任务 -->

      <el-dialog
        :title="$t('formValidation.manuallyCreateInspectionTasks')"
        :visible.sync="tasksvidible"
        center
        top="14vh"
        width="1200px"
        append-to-body
      >
        <el-form
          :model="taskModel"
          :inline="true"
          ref="editForm"
          :rules="editFormRules"
          label-width="115px"
        >
          <el-row :gutter="24" class="form">
            <el-col :span="8">
              <el-form-item
                :label="$t('inventoryManagement.materialName')"
                prop="materialName"
              >
                <material-dialog
                  v-model="taskModel.materialName"
                  @callback="(row) => materialDataCallback(row)"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('inventoryManagement.materialNo')"
                prop="materialCode"
              >
                <el-input
                  v-model="taskModel.materialCode"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('inventoryManagement.factory')"
                prop="factoryCode"
              >
                <el-input
                  v-model="taskModel.factoryCode"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="form">
            <el-col :span="8">
              <el-form-item :label="$t('inspectionManagement.lot')" prop="lot">
                <el-input
                  v-model="taskModel.lot"
                  clearable
                  style="width: 100%"
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('inventoryManagement.batchQuantityTotal')"
                prop="batchAmount"
              >
                <el-input
                  v-model="taskModel.batchAmount"
                  clearable
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('inspectionManagement.cputime')"
                prop="cputime"
              >
                <!-- <el-input v-model="taskModel.cputime" clearable disabled size="small" /> -->
                <el-date-picker
                  v-model="taskModel.cputime"
                  type="date"
                  placeholder="选择日期"
                  size="small"
                  value-format="yyyy-MM-dd"
                ></el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="form">
            <el-col :span="8">
              <el-form-item
                :label="$t('inspectionManagement.deliveryDate')"
                prop="deliveryDate"
              >
                <!-- <el-input v-model="taskModel.deliveryDate" clearable  size="small" /> -->
                <el-date-picker
                  v-model="taskModel.deliveryDate"
                  type="date"
                  placeholder="选择日期"
                  size="small"
                  value-format="yyyy-MM-dd"
                  style="width: 100%"
                ></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('inspectionStandards.division')"
                prop="divisionName"
              >
                <division-dialog
                  v-model="taskModel.divisionName"
                  :divisionId.sync="taskModel.divisionId"
                />
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                :label="$t('inventoryManagement.supplierName')"
                prop="supplierName"
              >
                <supplier-dialog
                  v-model="taskModel.supplierName"
                  @callback="(row) => supplierDataCallback(row)"
                />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="form">
            <el-col :span="8">
              <el-form-item
                :label="$t('inspectionManagement.inspectionPlanVersion')"
                prop="version"
              >
                <!-- <el-input v-model="taskModel.version" clearable size="small" disabled/> -->
                <el-select
                  v-model="taskModel.version"
                  :placeholder="
                    $t('public.select_holder', {
                      select_holder: $t('transferRules.currentTactics'),
                    })
                  "
                  clearable
                  size="small"
                >
                  <el-option
                    size="mini"
                    v-for="item in versionList"
                    :key="item"
                    :label="item"
                    :value="item"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('transferRules.currentTactics')"
                prop="currentTactics"
              >
                <!-- 当前策略 -->
                <el-select
                  v-model="taskModel.currentTactics"
                  @change="changeCurrentTactics"
                  :placeholder="
                    $t('public.select_holder', {
                      select_holder: $t('transferRules.currentTactics'),
                    })
                  "
                  clearable
                  size="small"
                >
                  <el-option
                    size="mini"
                    v-for="item in currentTacticslist"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="
                  $t('inventoryManagement.skipBatchExemptionFromInspection')
                "
                prop="exempted"
              >
                <el-radio-group v-model="taskModel.exempted">
                  <el-radio :label="1">{{ $t("public.yes") }}</el-radio>
                  <el-radio :label="0">{{ $t("public.no") }}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="form">
            <el-col :span="8">
              <el-form-item
                :label="$t('inspectionManagement.inspectionTaskType')"
                required
              >
                <el-select
                  v-model="taskModel.inspectionTaskType"
                  :placeholder="$t('public.selectPl')"
                  size="small"
                >
                  <el-option
                    size="mini"
                    v-for="item in taskTypeList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="form">
            <el-col :span="8">
              <el-form-item>
                <el-button type="primary" @click="getitemlist" size="small">{{
                  "获取检验项"
                }}</el-button>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="24">
              <div v-if="itemList.length > 0">
                <inspection-item-info-virtual
                  :isRecheck="true"
                  :isInventory="true"
                  ref="incomingSubmit1"
                  :itemData="itemList"
                  :disabled="true"
                  @callback="submitCallback"
                  :deleteable="true"
                ></inspection-item-info-virtual>
              </div>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            @click="submitAddForm(1)"
            :loading="loading"
            icon="el-icon-check"
            size="small"
            >{{ $t("public.define") }}
          </el-button>
        </div>
      </el-dialog>
      <!-- 创建虚拟物料任务 -->
      <el-dialog
        :title="$t('formValidation.createVirtualMaterialTask')"
        :visible.sync="virtualMaterialVisible"
        center
        top="14vh"
        width="1200px"
        append-to-body
        @close="closevirtualMaterial"
      >
        <el-form
          :model="virtualMaterialModel"
          :inline="true"
          ref="virtualMaterialForm"
          :rules="virtualMaterialFormRules"
          label-width="115px"
        >
          <el-row :gutter="24" class="form">
            <el-col :span="8">
              <el-form-item
                :label="$t('inventoryManagement.materialName')"
                prop="materialName"
              >
                <material-dialog
                  v-model="virtualMaterialModel.materialName"
                  @callback="(row) => virtualMaterialDataCallback(row)"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('inventoryManagement.materialNo')"
                prop="materialCode"
              >
                <el-input
                  v-model="virtualMaterialModel.materialCode"
                  clearable
                  disabled
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('inventoryManagement.batchQuantity')"
                prop="batchAmount"
              >
                <el-input
                  v-model="virtualMaterialModel.batchAmount"
                  clearable
                  size="small"
                />
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item
                :label="$t('transferRules.currentTactics')"
                prop="currentTactics"
              >
              <el-select
                v-model="virtualMaterialModel.currentTactics"
                size="small"
                @change="changeCurrentTacticsTask"
              >
                  <el-option
                    size="mini"
                    v-for="item in TacticsTaskList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                </el-option>
              </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24" class="form">
            <el-form-item
              :label="$t('inspectionManagement.associatedInspectNo')"
              prop="lot"
              style="display: flex; width: 100%"
            >
              <el-col
                :span="24"
                v-for="(value, index) in tempAssociationOrder"
                :key="index"
              >
                <el-input
                  :key="index"
                  v-model="tempAssociationOrder[index]"
                  clearable
                  size="small"
                  style="width: 200px"
                  @blur="
                    tempAssociationOrderBlur(tempAssociationOrder[index], index)
                  "
                />
                <el-button
                  @click="addInput"
                  size="small"
                  style="width: 30px; height: 30px; margin-left: 10px"
                  >+</el-button
                >
                <el-button
                  @click="removeInput(i)"
                  size="small"
                  style="width: 30px; height: 30px"
                  v-if="index > 0"
                  >-</el-button
                >
              </el-col>
            </el-form-item>
          </el-row>
          <el-row :gutter="24" class="form">
            <el-col :span="8">
              <el-form-item>
                <el-button type="primary" @click="getitemlist2" size="small">{{
                  "获取检验项"
                }}</el-button>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="24">
              <div v-if="itemList.length > 0">
                <inspection-item-info-virtual
                  :isRecheck="true"
                  :isInventory="true"
                  ref="incomingSubmit2"
                  :itemData="itemList"
                  :disabled="true"
                  @callback="submitCallback2"
                  :deleteable="true"
                ></inspection-item-info-virtual>
              </div>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            @click="submitAddForm(2)"
            :loading="loading"
            icon="el-icon-check"
            size="small"
            >{{ $t("public.define") }}
          </el-button>
        </div>
      </el-dialog>
      <!-- 发起过账 -->
      <el-dialog
        :title="$t('inspectionManagement.Initiateposting')"
        :visible.sync="batchNumVidible"
        center
        top="14vh"
        width="500px"
        append-to-body
        :fullscreen="fullscreen"
        @close="closeBatchNumVidible"
      >
        <el-form
          :model="batchNumForm"
          ref="batchNumForm"
          :rules="editFormRules"
          label-width="120px"
        >
          <el-form-item :label="$t('inspectionManagement.selectinspectionlotno')" prop="batchNum">
            <el-select
              v-model="batchNumForm.inspectionLotMark"
              size="small"
              @change="changeInspectionLot"
              style="width: 100%"
            >
              <el-option
                size="mini"
                v-for="item in inspectionLotMarklist"
                :key="item.inspectionLotMark"
                :label="item.inspectionLotMark"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('inspectionManagement.totalquantityposted')">
            <span>{{ allnum }}</span>
          </el-form-item>
          <el-form-item :label="$t('inspectionManagement.Unlimitedusagequantity')" prop="batchNum">
            <el-input-number
              v-model="batchNumForm.batchNumber"
              :step="0.001"
              step-strictly
              :min="0"
              size="mini"
              :controls="false"
            ></el-input-number>
          </el-form-item>
          <el-form-item :label="$t('inspectionManagement.Frozeninventoryquantity')" prop="freezeNum">
            <el-input-number
              v-model="batchNumForm.freezeNum"
              :step="0.001"
              step-strictly
              :min="0"
              size="mini"
              :controls="false"
            ></el-input-number>
          </el-form-item>
          <el-form-item :label="$t('inspectionManagement.returndeliveryquantity')" prop="backNum">
            <el-input-number
              v-model="batchNumForm.backNum"
              :step="0.001"
              step-strictly
              :min="0"
              size="mini"
              :controls="false"
            ></el-input-number>
          </el-form-item>
          <el-form-item :label="$t('inspectionManagement.accumulationofcurrentinspectionbatchposted')">
            <span>{{ inspectionLotMarkobj.accountAmount }}</span>
          </el-form-item>
          <el-form-item :label="$t('inspectionManagement.currentinspectionbatchno')">
            <span>{{ inspectionLotMarkobj.batchAmount }}</span>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="batchNumVidible = false" size="small">{{
            $t("public.close")
          }}</el-button>
          <el-button type="primary" @click="handleNumReview" size="small">{{
            $t("public.define")
          }}</el-button>
        </div>
      </el-dialog>

      <!--  -->
      <el-dialog
        :title="$t('inspectionManagement.inspectionResultsArePushedToMes')"
        :visible.sync="mesVidible"
        center
        top="14vh"
        width="500px"
        append-to-body
        :fullscreen="fullscreen"
      >
        <el-form
          :model="batchNumForm"
          ref="batchNumForm"
          label-position="top"
          :rules="editFormRules"
          label-width="120px"
        >
          <el-form-item :label="$t('inspectionManagement.InspectBatchNo')">
            <el-select
              v-model="inspectionLotMarkMes"
              clearable
              size="small"
              style="width: 100%"
            >
              <el-option
                size="mini"
                v-for="item in ispectionCodeLabel"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('inspectionManagement.inspectionresultsendtocellMES')" prop="backNum">
            <el-select
              v-model="mesBaseValue"
              clearable
              size="small"
              style="width: 100%"
            >
              <el-option
                size="mini"
                v-for="item in meslist"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="mesVidible = false" size="small">{{
            $t("public.close")
          }}</el-button>
          <el-button type="primary" @click="handlemesReview" size="small">{{
            $t("public.define")
          }}</el-button>
        </div>
      </el-dialog>

      <el-dialog
        :visible.sync="inspectionAndAuditOpen"
        center
        top="34vh"
        width="300px"
        append-to-body
        :fullscreen="fullscreen"
        @close="submitAuditClose"
      >
        <el-radio-group v-model="reportAuditStatus">
          <el-radio :label="1">{{ $t('inventoryManagement.pass') }}</el-radio>
          <el-radio :label="2">{{  $t('inventoryManagement.fail') }}</el-radio>
        </el-radio-group>
        <div slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            @click="submitAudit"
            icon="el-icon-check"
            size="small"
            >{{ $t("public.define") }}
          </el-button>
          <el-button
            @click="submitAuditCancel"
            icon="el-icon-close"
            size="small"
            >{{ $t("public.cancel") }}
          </el-button>
        </div>
      </el-dialog>
      <el-dialog
        :visible.sync="editItemDialogVisible"
        width="40%"
        @close="editItemDialogVisible = false"
        v-loading="loading"
      >
        <el-form
          ref="editItemForm"
          :model="editItem"
          label-position="left"
          label-suffix=":"
          label-width="90px"
          :rules="auditRules"
        >
          <el-form-item
            :label="$t('inspectionManagement.inspectNo')"
            prop="inspectNo"
          >
            <el-input
              v-model="editItem.inspectNo"
              :placeholder="
                $t('public.placeholder', {
                  placeholder: $t('inspectionManagement.inspectNo'),
                })
              "
              size="small"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer" style="text-align: center">
          <el-button @click="editItemDialogVisible = false">{{
            $t("public.cancel")
          }}</el-button>
          <el-button type="primary" @click="sava">{{
            $t("public.save")
          }}</el-button>
        </div>
      </el-dialog>
      <el-dialog
        :visible.sync="editItemDialogSupplierNames"
        width="40%"
        @close="editItemDialogSupplierNames = false,$refs['editItemFormSupplierNames'].resetFields()"
        v-loading="loading"
      >
        <el-form
          ref="editItemFormSupplierNames"
          :model="editItemFormSupplierNames"
          label-position="left"
          label-suffix=":"
          label-width="90px"
          :rules="SupplierNamesAuditRules"
        >
          <el-form-item
            label="初始供应商名称"
            prop="OriginSupplierName"
          >
            <el-input
              v-model="editItemFormSupplierNames.OriginSupplierName"
              type='textarea'
              disabled
              size="small"
            />
          </el-form-item>
          <el-form-item
            label="当前供应商名称"
            prop="CurrentSupplierAliasName"
          >
            <el-input
              v-model="editItemFormSupplierNames.CurrentSupplierAliasName"
              type='textarea'
              disabled
              size="small"
            />
          </el-form-item>
          <el-form-item
            label="修改为"
            prop="supplierAliasName"
          >
            <el-input
              v-model="editItemFormSupplierNames.supplierAliasName"
              :placeholder="
                $t('public.placeholder', {
                  placeholder: $t('inspectionManagement.supplierName'),
                })
              "
              size="small"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer" style="text-align: center">
          <el-button @click="editItemDialogSupplierNames = false,$refs['editItemFormSupplierNames'].resetFields()">{{
            $t("public.cancel")
          }}</el-button>
          <el-button type="primary" @click="savaSupplierNames">{{
            $t("public.save")
          }}</el-button>
        </div>
      </el-dialog>
      <el-dialog
        :visible.sync="selectCoaReportShow"
        width="40%"
        @close="selectCoaReportShow = false,$refs['selectCoaReportForm'].resetFields()"
        v-loading="loading"
      >
        <el-form
          ref="selectCoaReportForm"
          :model="selectCoaReportForm"
          label-position="left"
          label-suffix=":"
          label-width="120px"
          :rules="selectCoaReportFormRules"
        >
          <el-form-item
            label="选择报告类型"
            prop="CoaReportType"
          >
            <el-radio-group v-model="selectCoaReportForm.CoaReportType">
              <el-radio v-for='item in selectCoaReportTypeList' :value='item.value' :label="item.value">{{item.name}}</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item
            label="选择文件类型"
            prop="CoaReportFile"
          >
            <el-radio-group v-model="selectCoaReportForm.CoaReportFile">
              <el-radio v-for='item in selectCoaReportFileList' :value='item.value' :label="item.value">{{item.name}}</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer" style="text-align: center">
          <el-button @click="selectCoaReportShow = false,$refs['selectCoaReportForm'].resetFields()">{{
            $t("public.cancel")
          }}</el-button>
          <el-button type="primary" @click="handleSelectCoa">{{
            $t("public.define")
          }}</el-button>
        </div>
      </el-dialog>
      <DialogXlsx
        :visible.sync="visibleXlsx"
        :excelHtml="excelHtml"
        :asyncFile="asyncFile"
      />
      <DialogPdf
        :visible.sync="visiblePdf"
        :pdfUrl='pdfUrl'
        :asyncFile='asyncFile'
      />
      <importDataDialog2 :visible.sync="templateVisible2" @callback="templateVisible2=false" ref="importDataDialog" :action="'/ny-iqc/template/checkValue/import'"/>
    </div>
  </list-layout>
</template>

<script>
import { getType, refreshCache } from "@/api/basic/dict/type";

import {
  addNcr,
  editAcceptReturns,
  getAcceptReturns,
  getAudit,
  getAuditCheck,
  getAuditEcho,
  getCollectionCheck,
  getInspectionCheck,
  getMinFlawAll,
  getNCRDetail,
  getNcrReviewCheck,
  getPrintCheck,
  getReleaseApproval,
  getReleaseCheck,
  getReport,
  getReturn,
  returns,
  getReview,
  incomingList,
  checkReleaseApproval,
  getPlanItem,
  exportCoa,
  getSamplingTypeAPI,
  checkoutManualAPI,
  virtuallyCheckoutManualAPI,
  getVersion2,
  // auditCheck,
  auditBatch,
  listMesBaseDictAPI,
  inspectionResultPushMesAPI,
  raiseProduceTrail,
  salesReturn,
  inspectionReuse,
  incomingInspectionPushCrm,
  audit,
  getPassNumAPI,
  splitTransferItemsAPI,
  getExtraByInspectionIdAPI,
  getInfoByInspectionOrderAPI,
  getTacticsCarryOutByCode,
  updateSupplierAliasName
} from "@/api/inspectionManagement/inspectionManagement";
import { mapGetters, mapState } from "vuex";
import { listALLFactory } from "@/api/basic/factory";
import FileUpload from "@/components/FileUpload";
import oldVersionMain from "./oldVersionApproval/index.vue";
import printerDialog from "../../components/printerDialog";
import { listMaterialType } from "@/api/basic/materialtype";
import SelectUserDialog from "@/views/components/SelectUserDialog";
import { getToken } from "@/utils/auth";
import InspectionItemInfoVirtual from "@/views/components/InspectionItemInfoVirtual";
import MaterialDialog from "@/views/components/MaterialDialog";
import SupplierDialog from "@/views/components/SupplierDialog";
import DivisionDialog from "@/views/components/DivisionDialog";
import { undoToDo } from "@/api/notificationManager/notificationManager";
import { carryOutList } from "@/api/inspectionManagement/transferRules";
import DialogXlsx from "@/views/components/DialogXlsx";
import DialogPdf from "@/views/components/DialogPdf";
import * as XLSX from "xlsx/xlsx.mjs";
import importDataDialog2 from '@/views/components/importDialog/importData2.vue'
export default {
  name: "incoming",
  dicts: [
    "NYIQC_SHEET_STATUS", //检验单状态
    "NYIQC_NCR_DECISION", //使用决策
    "NYIQC_BATCH",
    "NYIQC_NCR_QCLASS",
    "NYIQC_EXEMPTEDOASTATUS", //免检审批状态
    "NYIQC_EXEMPTED", //免检
    "NYIQC_AUDIT_RESULT",
    "NYIQC_CE_STRATEGY",
    "NYIQC_RULE_TACTICS",
  ],
  components: {
    FileUpload,
    oldVersionMain,
    printerDialog,
    SelectUserDialog,
    InspectionItemInfoVirtual,
    MaterialDialog,
    SupplierDialog,
    DivisionDialog,
    DialogXlsx,
    importDataDialog2,
    DialogPdf
  },
  data() {
    return {
      selectCoaReportTypeList:[
        {name:'中文报告',value:'1'},
        {name:'英文报告',value:'2'},
        {name:'中英文报告',value:'3'},
      ],
      selectCoaReportFileList:[
        {name:'EXCEL',value:'1'},
        {name:'PDF',value:'2'},
      ],
      selectCoaReportForm:{
        CoaReportType:'1',
        CoaReportFile:'1'
      },
      selectCoaReportShow:false,
      selectCoaReportFormRules:{
      CoaReportType: [{ required: true, message: "报告类型不能为空" }],
      CoaReportFile: [{ required: true, message: "文件类型不能为空" }],
      },
      templateVisible2:false,
      editItemFormSupplierNames:{
        CurrentSupplierAliasName:'',
        supplierAliasName:'',
        OriginSupplierName:''
      },
      SupplierNamesAuditRules:{
        supplierAliasName: [{ required: true, message: "新的供应商名称不能为空" }],
      },
      editItemDialogSupplierNames:false,
      visibleXlsx: false,
      excelHtml: "",
      asyncFile: null,
      visiblePdf: false,
      pdfUrl:'',
      currentTacticslist: [],
      batchAmountlist: [],
      mesobj: {},
      editItem: {},
      editItemDialogVisible: false,
      mesVidible: false,
      batchNumVidible: false,
      tasksvidible: false,
      virtualMaterialVisible: false,
      editFormRules: {
        materialName: [
          {
            required: true,
            message: this.$t("formValidation.materialNameCannotBeEmpty"),
          },
        ],
        lot: [{ required: true, message: "批次号不能为空" }],
        batchAmount: [{ required: true, message: "总计批数量不能为空" }],
        cputime: [{ required: true, message: "到货日期不能为空" }],
        deliveryDate: [{ required: true, message: "报检日期不能为空" }],
        exempted: [{ required: true, message: "是否免检不能为空" }],
        supplierName: [{ required: true, message: "供应商名称不能为空" }],
        inspectionTaskType: [
          {
            required: true,
            message: "必填",
            trigger: "blur",
          },
        ],
        version: [
          {
            required: true,
            message: "检验标准版本号不能为空",
            trigger: "change",
          },
        ],
        divisionName: [
          {
            required: true,
            message: this.$t("formValidation.businessUnitCannotBeEmpty"),
          },
        ],
      },
      virtualMaterialFormRules: {
        materialName: [
          {
            required: true,
            message: this.$t("formValidation.materialNameCannotBeEmpty"),
          },
        ],
      },
      itemList: [],
      taskModel: {
        exempted: 0,
        inspectionTaskType: 1,
      },
      tempAssociationOrder: [""],
      virtualMaterialModel: {
        isVirtually: 1,
        associationOrder: "",
        batchAmount: 0,
        currentTactics:''
      },
      TacticsTaskList:[],
      batchNumForm: {
        batchNumber: 0,
        freezeNum: 0,
        backNum: 0,
        inspectionLotMark: "",
      },
      direction: "rtl",
      factoryList: [],
      optionLoading: false,
      returnInspection: false,
      returnKey: 0,
      releaseForm: {
        release: "1",
      },
      releaseOpen: false,
      columns: [
        {
          key: 0,
          label: this.$t("inventoryManagement.factory"),
          visible: true,
        },
        {
          key: 1,
          label: "检验单号",
          visible: true,
        },
        {
          key: 2,
          label: this.$t("inventoryManagement.inspectionOrderstatus"),
          visible: true,
        },
        {
          key: 3,
          label: this.$t("inventoryManagement.arrivalTime"),
          visible: true,
        },
        {
          key: 4,
          label: this.$t("inspectionManagement.inspectionStartTime"),
          visible: true,
        },
        {
          key: 5,
          label: "检验项进度",
          visible: true,
        },
        {
          key: 6,
          label: "MSL等级",
          visible: true,
        },
        {
          key: 7,
          label: this.$t("inventoryManagement.materialNo"),
          visible: true,
        },
        {
          key: 8,
          label: this.$t("inventoryManagement.materialName"),
          visible: true,
        },
        {
          key: 9,
          label: "规格型号",
          visible: true,
        },
        {
          key: 10,
          label: this.$t("inventoryManagement.supplierName"),
          visible: true,
        },
        {
          key: 11,
          label: this.$t("inventoryManagement.batchQuantity"),
          visible: true,
        },
        {
          key: 12,
          label: this.$t("inventoryManagement.unit"),
          visible: true,
        },
        {
          key: 13,
          label: this.$t("inventoryManagement.judgmentResult"),
          visible: true,
        },
        {
          key: 14,
          label: "检验员",
          visible: true,
        },
        {
          key: 15,
          label: "描述",
          visible: true,
        },
        {
          key: 16,
          label: this.$t("performanceManagement.reviewer"),
          visible: true,
        },
        {
          key: 17,
          label: this.$t("inventoryManagement.realityAuditName"),
          visible: true,
        },
        {
          key: 18,
          label: this.$t("performanceManagement.auditOpinion"),
          visible: true,
        },
        {
          key: 19,
          label: this.$t("inspectionManagement.approvalReason"),
          visible: true,
        },
        {
          key: 20,
          label: this.$t("inventoryManagement.useDecision"),
          visible: true,
        },
        {
          key: 21,
          label: this.$t("inspectionManagement.inspectionEndtTime"),
          visible: true,
        },
        {
          key: 22,
          label: this.$t("inventoryManagement.maturity"),
          visible: true,
        },
        {
          key: 23,
          label: this.$t("inventoryManagement.inspectionBatchNo"),
          visible: true,
        },
        {
          key: 24,
          label: this.$t("inspectionManagement.isInspectionExemption"),
          visible: true,
        },
        {
          key: 25,
          label: this.$t("inventoryManagement.batch"),
          visible: true,
        },
        {
          key: 26,
          label: this.$t("inventoryManagement.supplierNo"),
          visible: true,
        },
        {
          key: 27,
          label: this.$t("inspectionManagement.isPass"),
          visible: true,
        },
        {
          key: 28,
          label: this.$t("inspectionManagement.isInspection"),
          visible: true,
        },
        {
          key: 29,
          label: this.$t("inspectionManagement.inspectionDuration"),
          visible: true,
        },
        {
          key: 30,
          label: this.$t("inspectionManagement.standardDuration"),
          visible: true,
        },
        {
          key: 31,
          label: this.$t("inventoryManagement.recheckSheet"),
          visible: true,
        },
        {
          key: 32,
          label: "采购订单号",
          visible: true,
        },
        {
          key: 33,
          label: "申请人",
          visible: true,
        },

        {
          key: 34,
          label: "库位编号",
          visible: true,
        },
        {
          key: 35,
          label: "库位名称",
          visible: true,
        },
        {
          key: 36,
          label: "入库结果",
          visible: true,
        },
        {
          key: 37,
          label: this.$t("inspectionManagement.lot"),
          visible: true,
        },
        {
          key: 38,
          label: this.$t("inspectionManagement.deliveryDate"),
          visible: true,
        },
        {
          key: 39,
          label: this.$t("inspectionManagement.isBatch"),
          visible: true,
        },
        {
          key: 40,
          label: this.$t("inspectionManagement.whetherTrial"),
          visible: true,
        },
        {
          key: 41,
          label: this.$t("inspectionManagement.cputime"),
          visible: true,
        },
        {
          key: 42,
          label: this.$t("inspectionManagement.COA"),
          visible: true,
        },
      ],
      printerVisible: false,
      printerUsingDecision: null,
      addInspection: false,
      minFlawOptions: [],
      showSearch: true,
      tableHeight: "calc(100vh - 308px)",
      printerId: null,
      previewModel: {},
      ncrRefresh: 0,
      ncrModel: {
        ncrType: 0,
      },
      returnList: [],
      factoryList: [],
      drawer: false,
      approvalOpen: false,
      printerOpen: false,
      inspectionAndAuditOpen: false,
      flag: false,
      printerForm: {},
      viewModel: {
        isContain: "0",
      },
      editModel: {
        inspectionInformation: "0",
      },
      auditCause: null,
      expireTimeOptions: [],
      approvalModel: {
        auditResult: "0",
        auditNotifier: null,
        auditCause: "",
        initiatorDept: "",
        initiatorName: "",
      },
      selBtn: 1,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      stemList: [],
      // 总条数
      total: 0,
      // 字典表格数据
      incomingList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      selectRows: [],
      rowifInspect: "",
      reportAuditStatus: "",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        inspectionTaskType: "",
        factoryName: "",
        lichn: "",
        lot: "",
        materialName: "",
        supplierCode: "",
        sheetStatus: ["9"],
        decideResult: undefined,
        dataSource: null,
        exempted: "",
        usingDecision: "",
        inspectionLotMark: null,
        inspectionTime: [],
        checkoutEndTime: [],
        reportAuditTime: [],
        materialLevel:"",
        materialKind:"",
        params: {
          beginTime: "",
          endTime: "",
          endBeginTime: "",
          endEndTime: "",
          reportAuditBeginTime: "",
          reportAuditEndEndTime: "",
        },
        materialCode: "",
        materialType: undefined,
        materialMin: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        dictName: [
          {
            required: true,
            message: "字典名称不能为空",
            trigger: "blur",
          },
        ],
        dictType: [
          {
            required: true,
            message: "字典类型不能为空",
            trigger: "blur",
          },
        ],
      },
      // 表单校验
      auditRules: {
        inspectNo: [
          {
            required: true,
            message: "检验单号不能为空",
            trigger: "blur",
          },
        ],
      },
      fullscreen: false,
      oldVersionVisiable: false,
      incomingKey: 0,
      versionList: [],
      meslist: [],
      ispectionCodeLabel: [],
      mesBaseValue: "",
      inspectionLotMarkMes: "",
      inspectionLotMarklist: [],
      inspectionLotMarkobj: {
        batchAmount: "",
        accountAmount: "",
      },
      // 物料等级
      materialLevelList: [
        { value: "1", label: this.$t("inspectionManagement.CategoryAMaterial") },
        { value: "2", label: this.$t("inspectionManagement.CategoryBMaterial") },
        { value: "3", label: this.$t("inspectionManagement.CategoryCMaterial") },
        { value: "4", label: this.$t("inspectionManagement.CategoryDMaterial") },
      ],
      // 物料类型编码
      materialKindList: [
        { value: "1", label: this.$t("inspectionManagement.MainMaterial") },
        { value: "2", label: this.$t("inspectionManagement.rawMaterial") },
      ],

      taskTypeList: [
        {
          label: this.$t("inspectionManagement.incomingInspection"),
          value: 1,
        },
        {
          label: this.$t("inventoryManagement.inventoryInspection"),
          value: 2,
        },
      ],
    
      allchecked6:[],
    }
  },
  created() {
    let id = this.$route.query.id;
    let scene = this.$route.query.scene;
    //回调调用 OA待办转已办 接口
    if (id != undefined && scene != undefined) {
      undoToDo(id, scene).then((res) => {
        if (res.code != 200) {
          this.$modal.msgError(res.msg);
        }
      });
      this.queryParams.id = id;
    }
  },
  mounted() {
    let incomingColumns = JSON.parse(localStorage.getItem("incomingColumns"));
    if (incomingColumns) {
      this.columns = JSON.parse(incomingColumns);
    }
    if (this.$route.query.status) {
      this.queryParams.sheetStatus = [this.$route.query.status];
      // if (!this.$route.query.ncr) {
      //     if (this.$route.query.type !== 'history') {
      //         this.queryParams.inspectionTime = [
      //             this.getNowDate(),
      //             this.getNowDate(),
      //         ]
      //     }
      // }
    }
    if (this.$route.query.exceedTimeStauts) {
      this.queryParams.exceedTimeStauts = this.$route.query.exceedTimeStauts;
    }
    if (this.$route.query.uniqueId) {
      this.queryParams.id = this.$route.query.uniqueId;
    }
    if (this.$route.query.status === "") {
      this.queryParams.sheetStatus = [];
    }
    // 合格数1
    if (this.$route.query.decideResult == 1) {
      this.queryParams.decideResult = this.$route.query.decideResult;
      this.queryParams.usingDecision = "";
      this.queryParams.sheetStatus = [];
    }
    // 特采数量1 退货数量3 挑选数量2
    if (
      this.$route.query.usingDecision == 1 ||
      this.$route.query.usingDecision == 2 ||
      this.$route.query.usingDecision == 3
    ) {
      this.queryParams.usingDecision = this.$route.query.usingDecision;
      this.queryParams.decideResult = "";
      this.queryParams.sheetStatus = [];
    }
    // 检验/审批中 1,2,3,6,10
    if (this.$route.query.sheetStatus) {
      if(this.$route.query.sheetStatus==='ALL'){
        this.queryParams.sheetStatus = []
      }else{
        this.queryParams.sheetStatus = this.$route.query?.sheetStatus.split(",");
      }

      this.queryParams.decideResult = "";
      this.queryParams.usingDecision = "";
    }
    this.initquery(this.$route.query)
    // this.getList()
   this.getFactoryList()
  },
  activated() {
    if (this.$route.query.status) {
      this.queryParams.sheetStatus = [this.$route.query.status];
      // if (!this.$route.query.ncr) {
      //     if (this.$route.query.type !== 'history') {
      //         this.queryParams.inspectionTime = [
      //             this.getNowDate(),
      //             this.getNowDate(),
      //         ]
      //     }
      // }
      this.queryParams.exceedTimeStauts = undefined;
    }
    if (this.$route.query.exceedTimeStauts) {
      this.queryParams.sheetStatus = ["9"];
      this.queryParams.exceedTimeStauts = this.$route.query.exceedTimeStauts;
    }
    if (this.$route.query.uniqueId) {
      this.queryParams.sheetStatus = ["9"];
      this.queryParams.id = this.$route.query.uniqueId;
      this.queryParams.exceedTimeStauts = undefined;
    }
    if (this.$route.query.status === "") {
      this.queryParams.sheetStatus = [];
    }
    // 合格数1
    if (this.$route.query.decideResult == 1) {
      this.queryParams.decideResult = this.$route.query.decideResult;
      this.queryParams.usingDecision = "";
      this.queryParams.sheetStatus = [];
    }
    // 特采数量1 退货数量3 挑选数量2
    if (
      this.$route.query.usingDecision == 1 ||
      this.$route.query.usingDecision == 2 ||
      this.$route.query.usingDecision == 3
    ) {
      this.queryParams.usingDecision = this.$route.query.usingDecision;
      this.queryParams.decideResult = "";
      this.queryParams.sheetStatus = [];
    }
    // 检验/审批中 1,2,3,6,10
    if (this.$route.query.sheetStatus) {
      this.queryParams.sheetStatus = this.$route.query?.sheetStatus.split(",");
      this.queryParams.decideResult = "";
      this.queryParams.usingDecision = "";
    }
    this.initquery(this.$route.query)
    this.getList();
    // this.getFactoryList();
    this.getlistMesBaseDict();
  },

  computed: {
    ...mapGetters(["userId", "name", "deptName"]),
    ...mapState({
      isFold: (state) => state.app.isFold,
    }),
    allnum() {
      var batchNumber = this.batchNumForm.batchNumber || 0;
      var freezeNum = this.batchNumForm.freezeNum || 0;
      var backNum = this.batchNumForm.backNum || 0;

      return (
        Number(batchNumber) +
        Number(freezeNum) +
        Number(backNum)
      ).toFixed(3);
    },
  },
  watch: {
    isFold(val) {
      if (val === true) {
        this.tableHeight = "calc(100vh - 308px)";
      } else {
        this.tableHeight = "calc(100vh - 446px)";
      }
    },
  },
  methods: {
    exportCheckValue(){
      
      if (this.ids.length < 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      if(this.selectRows.some(item=>item.sheetStatus!=6)){
        this.$modal.msgWarning("当前选中项含有非待检验任务");
        return;
      }
        this.templateVisible2=true
        this.$refs.importDataDialog.loadFileParams.ids=this.ids.join(",")
        this.$refs.importDataDialog.inspectionOrder=this.selectRows.map(item=>item.inspectionOrder).join(',')
    },
    openDialogSupplierNames(){
      console.log(this.ids)
      if (this.ids.length < 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      this.editItemDialogSupplierNames = true
      this.editItemFormSupplierNames.CurrentSupplierAliasName = this.selectRows.map(val => {if(val.supplierAliasName){return val.supplierAliasName}}).join(',')
      this.editItemFormSupplierNames.OriginSupplierName = this.selectRows.map(val => {if(val.supplierName) {return val.supplierName}}).join(',')
    },
    savaSupplierNames(){
      this.$refs["editItemFormSupplierNames"].validate((valid) => {
        if (valid) {
          updateSupplierAliasName({idList:this.ids,supplierAliasName:this.editItemFormSupplierNames.supplierAliasName}).then(res => {
            if(res.code == 200){
              this.editItemDialogSupplierNames = false
              this.$modal.msgSuccess(res.msg)
              this.$refs["editItemFormSupplierNames"].resetFields()
              this.getList()
            }else{
              this.$modal.msgError(res.msg)
            }
          })
        }
      });
      
    },
       // 驾驶舱跳转
       initquery(query){

        // materialLevel 等级分类 materialLevel=1
        if (query.materialLevel) {
          this.queryParams.materialLevel =query.materialLevel
        }
        // materialKind 主辅材：materialKind=1
        if (query.materialKind) {
          this.queryParams.materialKind =query.materialKind
        }
        // result 判定结果: decideResult=1
        if (query.result==1) {
          this.queryParams.decideResult =query.result
        }
        //inspectionEndTime&inspectionStartTime 检验结束时间 inspectionTime=['2023-11-22','2023-11-22']
        if (query.inspectionEndTime) {
          this.queryParams.checkoutEndTime =[query.inspectionStartTime,query.inspectionEndTime]
        }
        // 供应商编号 supplierCode=1003970
        if (query.supplierCode) {
          this.queryParams.supplierCode =query?.supplierCode
        }
        // 检验单状态：MRB 已完成：sheetStatus=4 （sheetStatus固定为4）

        // 供应商名称 ---通过供应商编号来

        // 检验单状态：紧急放行审批中，待发 MRB，MRB 处理中，MRB 已完成，已完成，待过账 ：sheetStatus=1,2,3,6,10
        if (query.sheetStatus) {
          if (query.sheetStatus === 'ALL') {
            this.queryParams.sheetStatus = []
          } else {
            this.queryParams.sheetStatus = query?.sheetStatus.split(",");
          }

        }
      },
    getCurrentTacticsTask(Obj){
      getTacticsCarryOutByCode(Obj).then(res => {
        if(res.data){
          var typelist = this.dict.type.NYIQC_RULE_TACTICS;
          // typelist.filter(item=>item.value)
          var list = res.data.carryOutList;
          this.TacticsTaskList = [];
          for (let i = 0; i < typelist.length; i++) {
            for (let index = 0; index < list.length; index++) {
              if (list[index].currentTactics == typelist[i].value) {
                var data = {
                  ...typelist[i],
                  samplingType: list[index].samplingType,
                };
                this.TacticsTaskList.push(data);
                break;
              }
            }
          }
          if(res.data.current){
            this.virtualMaterialModel.currentTactics = res.data.current
            for (const iterator of this.TacticsTaskList) {
              if(res.data.current === iterator.value){
                this.virtualMaterialModel.samplingType = iterator.samplingType
              }
            }
          }
        }else{
          this.TacticsTaskList = []
          this.virtualMaterialModel.currentTactics = ''
        }
      }).catch((err) => {
          this.TacticsTaskList = []
          this.virtualMaterialModel.currentTactics = ''
      })
    },
    changeCurrentTacticsTask(val){
      this.virtualMaterialModel.currentTactics = val
      for (const iterator of this.TacticsTaskList) {
        if(val === iterator.value){
          this.virtualMaterialModel.samplingType = iterator.samplingType
        }
      }
      this.$forceUpdate()
    },
    getAllChecked(){
      this.virtualMaterialVisible = true
      if(this.queryParams.sheetStatus.indexOf('6') !== -1 && this.ids.length){
        let ary = []
        for (const iterator of this.incomingList) {
          if(this.ids.indexOf(iterator.id) !== -1){
            ary.push(iterator)
          }
        }
        let temp = JSON.parse(JSON.stringify(ary[0]))
        temp.plantCode = temp.factoryCode
        temp.plantName = temp.factoryName
        this.virtualMaterialDataCallback(temp)
        this.allchecked6 = ary
        this.tempAssociationOrder.splice(0,1)
        for (let index = 0; index < this.allchecked6.length; index++) {
          this.tempAssociationOrder.push(this.allchecked6[index].inspectionOrder)
          this.tempAssociationOrderBlur(this.allchecked6[index].inspectionOrder,index) 
        }
        // console.log(this.ids)
      }
    },
    tempAssociationOrderBlur(item, i) {
      if (!item) return;
      getInfoByInspectionOrderAPI(item).then((res) => {
        if (res.code == 200) {
          this.batchAmountlist[i] = parseFloat(res.msg);
          this.getallbatchAmount();
        }
      });
    },
    bsartTXT(txt) {
      var arr = ["A013", "A023", "A024", "A029", "A030", "A031", "A032"];

      if (txt) {
        return arr.includes(txt)
          ? this.$t("nyiqc.Notinspectedallot")
          : this.$t("nyiqc.Regularorder");
      } else {
        return this.$t("nyiqc.Regularorder");
      }
    },

    getallbatchAmount() {
      let sum = 0;
      for (let i = 0; i < this.batchAmountlist.length; i++) {
        sum += this.batchAmountlist[i];
      }
      this.$set(this.virtualMaterialModel, "batchAmount", sum);
    },
    addInput() {
      this.tempAssociationOrder.push(""); // 增加一个空字符串到数组中
    },
    removeInput(i) {
      this.tempAssociationOrder.splice(i, 1);
      this.batchAmountlist.splice(i, 1);
      this.getallbatchAmount();
    },
    sava() {
      this.$refs["editItemForm"].validate((valid) => {
        if (valid) {
          inspectionReuse({
            inspectionId: this.ids[0],
            inspectionOrder: this.editItem.inspectNo,
          }).then((res) => {
            if (res.code === 200) {
              getInspectionCheck({ id: this.ids[0] }).then(() => {
                this.$router.push({
                  path: "/addIncoming/index/" + this.ids[0],
                  query: { ifInspect: this.rowifInspect },
                });
              });
            }
          });
          this.editItem = {};
          this.editItemDialogVisible = false;
        }
      });
    },
    getColumnWidth(columnName) {
      const data = this.incomingList;
      const getTextWidth = (text) => {
        const canvas = document.createElement("canvas");
        const context = canvas.getContext("2d");
        context.font = "14px Arial"; // 设置字体大小和类型
        return context.measureText(text).width;
      };

      const columnValues = data.map((item) => item[columnName]);
      var maxTextWidth = Math.max(...columnValues.map(getTextWidth));
      if (columnValues[0] == undefined) {
        maxTextWidth = 150; //给默认表格宽度
      }
      return maxTextWidth * 1.5;
    },
    getlistMesBaseDict() {
      listMesBaseDictAPI().then((res) => {
        this.meslist = res.data;
      });
    },
    virtualMaterialDataCallback(row) {
      this.$set(this.virtualMaterialModel, "factoryCode", row.plantCode);
      this.$set(this.virtualMaterialModel, "materialName", row.materialName);
      this.$set(this.virtualMaterialModel, "materialCode", row.materialCode);
      this.$set(this.virtualMaterialModel, "version", row.version);
      this.getCurrentTacticsTask({factoryCode:row.plantCode,materialCode:row.materialCode})
      getVersion2({
        factoryCode: this.virtualMaterialModel.factoryCode,
        materielCode: this.virtualMaterialModel.materialCode,
      })
        .then((res) => {
          this.versionList = [];
          if (res.data?.length) {
            this.$set(this.virtualMaterialModel, "version", res.data[0]);
            this.versionList = res.data;
            this.$forceUpdate();
          } else {
            this.virtualMaterialModel.version = "";
            this.$modal.msgError("暂无版本号");
          }
        })
        .catch((error) => {
          this.virtualMaterialModel.version = undefined;
        });
    },
    changeCurrentTactics(e) {
      console.log(e, this.currentTacticslist);
      var data = this.currentTacticslist.find((item) => item.value == e);
      this.$set(this.taskModel, "currentTactics", data.value);
      this.$set(this.taskModel, "samplingType", data.samplingType);
      this.itemList = [];
    },
    materialDataCallback(row) {
      console.log(row);

      this.$set(this.taskModel, "materialName", row.materialName);
      this.$set(this.taskModel, "materialCode", row.materialCode);
      this.$set(this.taskModel, "materialType", row.materialType);

      // 带出厂区
      this.$set(this.taskModel, "factoryCode", row.plantCode);
      this.$set(this.taskModel, "factoryName", row.plantName);

      getSamplingTypeAPI({
        materielCode: row.materialCode,
        factoryCode: this.taskModel.factoryCode,
      }).then((res) => {
        this.remoteFatch(res.data);
        this.$set(this.taskModel, "currentTactics", res.data.currentTactics);
        this.$set(this.taskModel, "samplingType", res.data.samplingType);
      });

      this.buildVersion();
    },

    // 当前策略远程搜索方法
    remoteFatch(record) {
      carryOutList({ ruleCode: record?.ruleCode })
        .then((res) => {
          if (Array.isArray(res.rows)) {
            var typelist = this.dict.type.NYIQC_RULE_TACTICS;
            // typelist.filter(item=>item.value)
            var list = res.rows;
            this.currentTacticslist = [];
            for (let i = 0; i < typelist.length; i++) {
              for (let index = 0; index < list.length; index++) {
                if (list[index].currentTactics == typelist[i].value) {
                  var data = {
                    ...typelist[i],
                    samplingType: list[index].samplingType,
                  };
                  this.currentTacticslist.push(data);
                  break;
                }
              }
            }
          } else {
            this.currentTacticslist = [];
          }
        })
        .finally(() => {});
    },
    buildVersion() {
      if (this.taskModel.materialCode && this.taskModel.factoryCode) {
        getVersion2({
          factoryCode: this.taskModel.factoryCode,
          materielCode: this.taskModel.materialCode,
        })
          .then((res) => {
            this.versionList = [];
            if (res.data?.length) {
              this.$set(this.taskModel, "version", res.data[0]);
              this.versionList = res.data;
              this.$refs.editForm.clearValidate("version");
              this.$forceUpdate();
            } else {
              this.taskModel.version = "";
              this.$modal.msgError("暂无版本号");
            }
          })
          .catch((error) => {
            this.taskModel.version = undefined;
          });
      } else {
        this.$modal.msgError("物料和厂区不能为空！");
      }
    },
    supplierDataCallback(row) {
      console.log(row);
      this.$set(this.taskModel, "supplierName", row.supplierName);
      this.$set(this.taskModel, "supplierCode", row.supplierCode);
    },
    getitemlist() {
      this.$refs["editForm"].validate((valid) => {
        if (valid) {
          if (!this.taskModel.version) {
            this.$message.error("检验标准版本号不能为空");
            return;
          }
          var data = {
            amendBatch: "",
            batchAmount: this.taskModel.batchAmount, // 36.000
            factoryCode: this.taskModel.factoryCode, //'1901' this.taskModel.factoryCode
            materialCode: this.taskModel.materialCode, //,// '26006727'
            supplierCode: this.taskModel.supplierCode, //,//1003970
            version: this.taskModel.version, //
            samplingType: this.taskModel.samplingType,
          };
          console.log(data);
          getPlanItem(data).then((res) => {
            if (res.data) {
              this.itemList = res.data ? res.data : [];
            } else {
              this.$message.error("暂无检验项");
            }
          });
        }
      });
    },
    getitemlist2() {
      this.$refs["virtualMaterialForm"].validate((valid) => {
        if (valid) {
          if (!this.virtualMaterialModel.version) {
            this.$message.error("检验标准版本号不能为空");
            return;
          }
          if (this.tempAssociationOrder.length >= 1) {
            this.virtualMaterialModel.associationOrder =
              this.tempAssociationOrder.join(",");
          }
          getPlanItem(this.virtualMaterialModel).then((res) => {
            if (res.data) {
              this.itemList = res.data ? res.data : [];
            } else {
              this.$message.error("暂无检验项");
            }
          });
        }
      });
    },
    handleReturns() {
      if (this.ids.length !== 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      // 待检验可退回 sheetStatus 为空时默认为待检验
      // let canReturn = this.incomingList.find(e => (e.id === this.ids[0]) && (e.sheetStatus === '6' || !e.sheetStatus))
      // if(canReturn){
      returns(this.ids[0]).then((response) => {
        this.$modal.msgSuccess("退回成功!");
        this.getList();
      });
      // }else{
      // this.$modal.msgWarning(
      // this.$t('inspectionManagement.onlyTheCondition')
      // )
      // }
    },

    handleInspectionAndAudit() {
      debugger;
      if (this.ids.length < 1) {
        this.$modal.msgWarning(
          this.$t("inspectionManagement.pleaseSelectLeastOne")
        );
        return;
      }
      this.inspectionAndAuditOpen = true;
    },
    handleExpireTime() {},
    submitCallback(params) {
      this.loading = true;

      let submitData = {
        ...this.taskModel,
        classList: params ? [...params] : undefined,
        dataSource: "进料",
        isRecheck: "0",
        dataIdent: "SAP",
        // "divisionName": "上饶",
        // "divisionId": "1684398555260784642",
        ttTacticsMaterielBind: {
          samplingAmount: "0",
        },
      };
      checkoutManualAPI(submitData)
        .then((response) => {
          if (response.code == 200) {
            this.$modal.msgSuccess("发起成功");
            this.tasksvidible = false;
            this.taskModel = {};
            this.itemList = [];
            this.getList();
          } else {
            this.$modal.msgError(response.msg);
            this.loading = false;
          }
        })
        .catch((error) => {
          this.loading = false;
        });
    },
    submitCallback2(params) {
      this.loading = true;

      let submitData = {
        ...this.virtualMaterialModel,
        classList: params ? [...params] : undefined,
        dataSource: "进料",
        isRecheck: "0",
        dataIdent: "SAP",
        virtuallyTaskSource: "2",
      };
      virtuallyCheckoutManualAPI(submitData)
        .then((response) => {
          if (response.code == 200) {
            this.$modal.msgSuccess("创建成功");
            this.virtualMaterialVisible = false;
            this.taskModel = {};
            this.itemList = [];
            this.getList();
          } else {
            this.$modal.msgError(response.msg);
            this.loading = false;
          }
        })
        .catch((error) => {
          this.loading = false;
        });
    },
    changeFlaw(item, scope, index) {
      this.ncrModel.voList[scope.$index].flawList[index].minFlawName =
        item.minFlawName;
      this.ncrModel.voList[scope.$index].flawList[index].minFlawCode =
        item.minFlawCode;
      this.ncrModel.voList[scope.$index].flawList[index].minFlawId = item.id;
      console.log(item, "==============");
    },
    deleteFlaw(scope) {
      this.ncrModel.voList[scope.$index].flawList.splice(scope.$index, 1);
    },
    addFlaw(scope) {
      this.ncrModel.voList[scope.$index].flawList.push({
        minFlawNr: null,
        minFlawName: null,
        minFlawId: null,
        minFlawCode: null,
        classId: this.ids.join(","),
      });
    },
    getFactoryList() {
      listAllFactory().then((res) => {
        this.factoryList = res.data;
      });
    },
    handleSave(row, index) {
      console.log("flag===", this.flag);
      if (this.flag) {
        return;
      }
      this.flag = true;
      editAcceptReturns(row)
        .then((res) => {
          this.$nextTick(() => {
            this.returnList[index] = res.data;
            this.returnKey++;
          });
          this.flag = false;
          this.$modal.msgSuccess("操作成功!");
        })
        .catch((err) => {
          this.returnList[index].storageFailure = err;
          this.flag = false;
        });
    },
    returnChange(val, row, index) {
      this.returnList[index].acceptAmount = (
        parseFloat(row.batchAmount) - parseFloat(val)
      ).toFixed(0);
    },
    acceptChange(val, row, index) {
      this.returnList[index].returnAmount = (
        parseFloat(row.batchAmount) - parseFloat(val)
      ).toFixed(0);
    },
    handleReFixed(row) {
      getAcceptReturns({ id: row.id }).then((res) => {
        this.returnList = res.data;

        this.returnInspection = true;
      });
    },
    formatCE_STRATEGY(e) {
      if (e) {
        let obj = this.dict.type.NYIQC_CE_STRATEGY.find((item) => {
          return item.value === e;
        });
        if (obj) {
          return obj.label;
        } else {
          return "";
        }
      } else {
        return "";
      }
    },
    handleReleaseOpen() {
      if (this.ids.length < 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      checkReleaseApproval({ids:this.ids}).then((res) => {
        if (res.code == 200) return (this.releaseOpen = true);
        this.$modal.msgError(res.msg);
      });
      // console.log('验证紧急放行')
      // this.releaseOpen = true
    },
    submitRelease() {
      getReleaseApproval({
        ids: this.ids,
        release: this.releaseForm.release,
      }).then((res) => {
        res.code == 200 ? this.$modal.msgSuccess(res.msg) : this.$modal.msgError(res.msg)
        this.releaseOpen = false;
        this.getList();
      });
    },
    userDataCallback(userId) {
      this.approvalModel.auditNotifierId = userId;
      this.$refs.approvalModel.validateField("auditNotifier");
    },
    formatAuditOpinion(e) {
      if (e) {
        let obj = this.dict.type.NYIQC_AUDIT_RESULT.find((item) => {
          return item.value === e;
        });
        if (obj) {
          return obj.label;
        } else {
          return "";
        }
      } else {
        return "";
      }
    },
    incomingFileChange(e) {
      let ids = e.map((item) => item.id);
      console.log("-------", ids);
      if (ids.length) {
        this.approvalModel.fileId = ids.join(",");
      }
    },
    showSelect(e, materialType) {
      if (e) {
        this.optionLoading = true;
        getMinFlawAll({}).then((res) => {
          this.minFlawOptions = res.data;
          this.optionLoading = false;
        });
      }
      console.log(e);
    },
    columnsCallback(incomingColumns) {
      console.log("incomingColumns", incomingColumns);
      localStorage.setItem("incomingColumns", JSON.stringify(incomingColumns));
      this.incomingKey++;
    },
    materialTypeRemoteMethod(val, cb) {
      listMaterialType({ typeName: val }).then((res) => {
        cb(res.rows);
      });
    },
    handleMaterialTypeSelect(e, scope) {
      // this.dialogForm.materialType = e
      this.queryParams.materialMin = e.typeName;
      this.$forceUpdate();
    },
    formatExemptedOaStatus(e) {
      if (e) {
        let obj = this.dict.type.NYIQC_EXEMPTEDOASTATUS.find((item) => {
          return item.value === e;
        });
        if (obj) {
          return obj.label;
        } else {
          return "";
        }
      } else {
        return "";
      }
    },
    // 获取小缺陷
    getMinFlaw() {
      // getMinFlawAll().then((res) => {
      //     this.minFlawOptions = res.data
      // })
    },
    formatOrderStatus(e) {
      var statue = e ? e : "6";
      if (statue) {
        let obj = this.dict.type.NYIQC_SHEET_STATUS.find((item) => {
          return item.value === statue;
        });
        if (obj) {
          return obj.label;
        } else {
          return "";
        }
      } else {
        return "待检验";
      }
    },
    formatApprovalStatus(e) {
      if (e == "1") {
        return this.$t('inventoryManagement.pass');
      } else if (e == "2") {
        return this.$t('inventoryManagement.fail');
      } else {
        return this.$t('inventoryManagement.audit');
      }
    },
    formatUsingDecision(e) {
      if (e) {
        let obj = this.dict.type.NYIQC_NCR_DECISION.find((item) => {
          return item.value === e;
        });
        console.log(e);
        if (obj) {
          return obj.label;
        } else {
          return "";
        }
      } else {
        return "";
      }
    },
    formatUsingDecisionTag(e) {
      if (e) {
        let obj = this.dict.type.NYIQC_NCR_DECISION.find((item) => {
          return item.value === e;
        });
        if (obj) {
          if (obj.label === "合格接受") {
            return "greenTag";
          } else if (obj.label === "不接受") {
            return "redTag";
          } else {
            return "yellowTag";
          }
        }
      } else {
        return "";
      }
    },
    // 检验单状态变色
    sheetColorChange(row) {
      switch (row.sheetStatus) {
        case "0":

        case "1":
        case "2":
          return "labelColor1";
        case "3":
          return "labelColor0";
        case "4":
        case "5":
          return "labelY";
        default:
          // if (row.sheetStatus) {
          return "labelColor1";
        // }
      }
    },
    // 检验单状态变色
    approvalStatusColorChange(row) {
      switch (row.reportAuditStatus) {
        case "1":
          return "labelY";
        default:
          // if (row.sheetStatus) {
          return "labelColor1";
        // }
      }
    },
    oaStatusColorChange(status) {
      switch (status) {
        case "0":
          return "labelY";
        case "1":
          return "labelColor0";
        case "2":
          return "labelColor1";
      }
    },
    //
    formatTactics(e) {
      if (e) {
        let obj = this.dict.type.NYIQC_RULE_TACTICS.find(
          (item) => item.value === e
        );
        return obj?.label;
      }
      return "";
    },
    submitNcrForm() {
      let files = [];
      if (this.ncrModel.file1) {
        files.push(this.ncrModel.file1);
      }
      if (this.ncrModel.file2) {
        files.push(this.ncrModel.file2);
      }
      let submitData = {
        ...JSON.parse(JSON.stringify(this.ncrModel)),
        flawBizType: "FLAW_UPLOAD",
        specificationBizType: "SPECIFICATION_UPLOAD",
        fileId: files.join(","),
      };
      submitData.voList.forEach((io) => {
        io.flawChoice = io.flawChoice ? io.flawChoice.join(";") : "";
      });
      delete submitData.file1;
      delete submitData.file2;
      addNcr(submitData)
        .then((response) => {
          this.$modal.msgSuccess("提交成功");
          this.addInspection = false;
          this.getList();
        })
        .catch(() => {});
    },
    changeStem(e, scope, index) {
      this.ncrModel.voList[scope.$index].stemVoList[index].stemName = e;
      this.ncrRefresh = this.ncrRefresh + 1;
    },
    changeStemNumber(e, scope, index) {
      this.ncrModel.voList[scope.$index].stemVoList[index].stemNumber = e;
      this.ncrRefresh = this.ncrRefresh + 1;
    },
    addStem(scope) {
      let stemVoList = scope.row.stemVoList;
      console.log(this.ncrModel.voList[scope.$index].stemVoList);
      this.ncrModel.voList[scope.$index].stemVoList.push({});
      this.ncrRefresh = this.ncrRefresh + 1;
    },
    deleteStem(scope, index) {
      if (this.ncrModel.voList[scope.$index].stemVoList.length === 1) {
        this.$modal.msgWarning("请至少保留一条遏制信息!");
        return;
      }
      this.ncrModel.voList[scope.$index].stemVoList.splice(index, 1);
      this.ncrRefresh = this.ncrRefresh + 1;
    },
    factoryChange(e) {
      let obj = this.factoryList.find((item) => {
        return item.factoryName === e;
      });
      this.ncrModel.launchFactory = obj.factoryName;
    },
    getFactoryList() {
      listALLFactory().then((res) => {
        this.factoryList = res.data;
      });
    },
    drawerClose() {
      this.drawer = false;
    },
    getNowDate() {
      var date = new Date();
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      var d = date.getDate();
      //  当前日期
      return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);
    },
    /** 查询字典类型列表 */
    getList() {
      this.loading = true;
      let params = { ...this.queryParams };
      // params.maturity = params.maturity && params.maturity.join(',')
      params.sheetStatus = params.sheetStatus && params.sheetStatus.join(",");
      if (params.inspectionTime && params.inspectionTime.length) {
        params.params.beginTime = params.inspectionTime[0];
        params.params.endTime = params.inspectionTime[1];
      } else {
        params.params.beginTime = "";
        params.params.endTime = "";
      }
      delete params.inspectionTime;
      if (params.checkoutEndTime && params.checkoutEndTime.length) {
        params.params.endBeginTime = params.checkoutEndTime[0];
        params.params.endEndTime = params.checkoutEndTime[1];
      } else {
        params.params.endBeginTime = "";
        params.params.endEndTime = "";
      }
      delete params.checkoutEndTime;
      if (params.reportAuditTime && params.reportAuditTime.length) {
        params.params.reportAuditBeginTime = params.reportAuditTime[0];
        params.params.reportAuditEndEndTime = params.reportAuditTime[1];
      } else {
        params.params.reportAuditBeginTime = "";
        params.params.reportAuditEndEndTime = "";
      }
      delete params.reportAuditTime;
      incomingList(params).then((response) => {
        if (response.code == 200 && response.rows) {
          this.incomingList = response.rows;
          let selectRows = [...this.selectRows];
          console.log("selectRows==============================", selectRows);
          if (selectRows.length > 0) {
            setTimeout(() => {
              this.incomingList.forEach((io) => {
                selectRows.forEach((ko) => {
                  console.log("true==============================");
                  if (io.id === ko.id) {
                    this.$refs.multipleTable.toggleRowSelection(io, true);
                  }
                });
              });
            }, 300);
          }
          this.total = response.total;
          this.loading = false;
          this.tableHeight = this.isFold
            ? "calc(100vh - 308px)"
            : "calc(100vh - 466px)";
        }
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      
      this.form = {
        dictId: undefined,
        dictName: undefined,
        dictType: undefined,
        status: "0",
        remark: undefined,
        inspectionTaskType: undefined,
      };

      this.resetForm("form");
      this.queryParams.sheetStatus = ["9"];
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.queryParams.exceedTimeStauts = null;
      this.queryParams.id = null;
      this.queryParams.inspectionTaskType = '';
      this.queryParams.materialLevel = '';
      this.queryParams.materialKind = '';
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleAddIncoming() {
      if (this.ids.length !== 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      if (this.selectRows[0].coverStatusVal === "是") {
        this.$modal.msgWarning(this.$t("当前任务为冲销任务，不可发起检验！"));
        return;
      }
      getInspectionCheck({ id: this.ids[0] }).then((response) => {
        this.$router.push({
          path: "/addIncoming/index/" + this.ids[0],
          query: { ifInspect: this.rowifInspect },
        });
      });
    },
    handleNcr() {
      if (this.ids.length !== 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      let selectRows = [...this.selectRows];
      selectRows.forEach((io) => {
        io.inspectionId = io.id;
        io.stemVoList = [{}];
      });
      console.log(this.selectRows);
      getNcrReviewCheck({ ids: this.ids.join(",") }).then((response) => {
        if (response.code === 200) {
          // 不走当前业务逻辑，直接转MRB发起页
          getNCRDetail({ ids: this.ids.join(",") }).then((res) => {
            if (res.code == 200) {
              this.$router.push({
                path: `/inventory/mrbReview/${res?.data?.id}`,
                query: { viewType: 1 },
              });
            }
          });
          return;
          getNCRDetail({ ids: this.ids.join(",") }).then((ncrData) => {
            if (ncrData.code === 200) {
              let voList = ncrData.data.voList;
              voList.forEach((element) => {
                element.stemVoList = [{}];
                element.flawChoice = element.flawChoice
                  ? element.flawChoice.split(";")
                  : element.flawChoice;
                element.flawList = [
                  {
                    minFlawNr: null,
                    minFlawName: null,
                    minFlawId: null,
                    minFlawCode: null,
                    classId: this.ids.join(","),
                  },
                ];
              });
              this.ncrModel = {
                voList: voList,
                whetherStem: "2",
                ncrType: ncrData.data.ncrType,
              };

              this.addInspection = true;
            }
          });
          this.getMinFlaw();
        }
      });
    },
    handlePrinter() {
      if (this.ids.length === 0) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      getPrintCheck({ ids: this.ids.join(",") }).then((response) => {
        if (response.code === 200) {
          this.printerOpen = true;
        }
      });
    },
    preHandleMes() {
      this.$modal
        .confirm(this.$t("formValidation.preConfirm"))
        .then(() => {
          if (this.selectRows.length > 0) {
            this.loading = true;
            let arys = [];
            for (let i = 0; i < this.selectRows.length; i++) {
              arys.push(this.selectRows[i].id);
            }
            incomingInspectionPushCrm(arys)
              .then((res) => {
                if (res.code == 200) {
                  this.$modal.msgSuccess(res.msg);
                  this.getList();
                } else {
                  this.$modal.msgWarning(res.msg);
                }
                this.loading = false;
              })
              .catch((err) => {
                this.loading = false;
              });
            // this.mesBaseValue = ""
            // this.preMesVidible = true
          } else {
            this.$modal.msgWarning(
              this.$t("inspectionManagement.pleaseSelectOne")
            );
          }
        })
        .catch(() => {});
    },

    handleReturn() {
      if (this.ids.length !== 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      getReturn({ id: this.ids[0] }).then((response) => {
        this.$modal.msgSuccess("退回成功!");
        this.getList();
      });
    },

    handleSelectUse(row) {
      this.$router.push({
        path: "/incomingDetail/selectUse/0",
        query: {
          id: row.id,
          materialCode: row.materialCode,
          materialName: row.materialName,
          supplierCode: row.supplierCode,
          inspectionLotMark: row.inspectionLotMark,
          lot: row.lot,
          ncrProcessId: row.ncrProcessId,
        },
      });
    },
    handleAddtionRecording() {
      if (this.ids.length !== 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      getCollectionCheck({ id: this.ids[0] }).then((response) => {
        this.$router.push({
          path: "/additionData/index/" + this.ids[0],
        });
      });
    },
    handlePass() {
      if (this.ids.length === 0) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      getReleaseCheck({ ids: this.ids.join(",") }).then((response) => {
        this.$router.push({ path: "/pass/index/" + this.ids.join(",") });
      });
    },
    /** 新增按钮操作 */
    handleAdd() {
      if (this.ids.length === 0) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      this.addInspection = true;
    },
    handleReview() {
      if (this.ids.length === 0) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      this.$modal
        .confirm(this.$t("formValidation.confirm"))
        .then(() => {
          getReview({ ids: this.ids.join(","), batchNumber: "" }).then(
            (response) => {
              this.$modal.msgSuccess("操作成功!");
              this.getList();
            }
          );
        })
        .catch(() => {});
    },
    handleMes() {
      if (this.selectRows.length == 1) {
        this.mesBaseValue = "";
        this.inspectionLotMarkMes = "";
        this.mesVidible = true;
        for (const iterator of this.incomingList) {
          if (this.ids[0] == iterator.id) {
            let temp = iterator.inspectionLotMark.split(";");
            let ispectionCodeLabel = [];
            for (const j of temp) {
              ispectionCodeLabel.push({ label: j, value: j });
            }
            this.ispectionCodeLabel = ispectionCodeLabel;
          }
        }
      } else {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
      }
    },
    preHandleMes() {
      this.$modal
        .confirm(this.$t("formValidation.preConfirm"))
        .then(() => {
          if (this.selectRows.length > 0) {
            this.loading = true;
            let arys = [];
            for (let i = 0; i < this.selectRows.length; i++) {
              arys.push(this.selectRows[i].id);
            }
            incomingInspectionPushCrm(arys)
              .then((res) => {
                if (res.code == 200) {
                  this.$modal.msgSuccess(res.msg);
                  this.getList();
                } else {
                  this.$modal.msgWarning(res.msg);
                }
                this.loading = false;
              })
              .catch((err) => {
                this.loading = false;
              });
            // this.mesBaseValue = ""
            // this.preMesVidible = true
          } else {
            this.$modal.msgWarning(
              this.$t("inspectionManagement.pleaseSelectOne")
            );
          }
        })
        .catch(() => {});
    },
    handleSalesReturn() {
      if (this.selectRows.length == 1) {
        if (this.selectRows[0].sheetStatus == "10") {
          //sheetStatus=='10' //待发MRB
          salesReturn({ id: this.ids[0] }).then((response) => {
            if (response.code === 200) {
              this.$modal.msgSuccess("操作成功!");
              this.getList();
            }
          });
        } else {
          this.$modal.msgWarning(this.$t('检验单非"待发MRB"状态'));
        }
      } else {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
      }
    },
    handleReuseInspectionValue() {
      if (this.ids.length !== 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      this.editItemDialogVisible = true;
    },
    showPostedQuantityDialog() {
      if (this.selectRows.length == 1) {
        var item = this.selectRows[0];
        getExtraByInspectionIdAPI(item.id).then((res) => {
          this.inspectionLotMarklist = res.data;
          this.batchNumForm = {
            batchNumber: 0,
            freezeNum: 0,
            backNum: 0,
            inspectionLotMark: "",
            extraId: "",
          };
          this.batchNumVidible = true;
        });
      } else {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
      }
    },
    closeBatchNumVidible() {
      this.inspectionLotMarkobj = {
        batchAmount: "",
        accountAmount: "",
      };
      this.inspectionLotMarklist = [];
    },
    changeInspectionLot(e) {
      var obj = this.inspectionLotMarklist.find((item) => item.id == e);
      var item = this.selectRows[0];
      var data = {
        isBatch: item.isBatch,
        inspectionLotMark: obj.inspectionLotMark,
        id: item.id,
        extraId: e,
      };
      this.batchNumForm.inspectionLotMark = obj.inspectionLotMark;
      this.batchNumForm.extraId = e;
      console.log(data);
      getPassNumAPI(data).then((res) => {
        this.inspectionLotMarkobj = res.data;
        this.inspectionLotMarkobj.accountAmount = res.data.accountAmount
          ? res.data.accountAmount
          : 0;
      });
    },
    handlemesReview() {
      var data = {
        inspectionLotMark: this.inspectionLotMarkMes,
        mesBaseValue: this.mesBaseValue,
        listInspectionId: [this.ids[0]],
      };

      inspectionResultPushMesAPI(data).then((res) => {
        this.mesVidible = false;

        this.$message.success("推送成功");
      });
    },
    handleNumReview() {
      if (!this.batchNumForm.extraId) {
        this.$modal.msgWarning("请选择检验批号");
        return;
      }
      var nownum = parseFloat(this.allnum) ? parseFloat(this.allnum) : 0;
      var batchAmount = this.inspectionLotMarkobj.batchAmount
        ? this.inspectionLotMarkobj.batchAmount
        : 0;
      var accountAmount = this.inspectionLotMarkobj.accountAmount
        ? this.inspectionLotMarkobj.accountAmount
        : 0;
      if (nownum > batchAmount - accountAmount) {
        this.$modal.msgWarning("过账数量不能超过原批数量");
        return;
      }
      this.$modal
        .confirm(this.$t("formValidation.confirm"))
        .then(() => {
          splitTransferItemsAPI({
            id: this.ids.join(","),
            batchNumber: this.batchNumForm.batchNumber + "",
            freezeNum: this.batchNumForm.freezeNum + "",
            backNum: this.batchNumForm.backNum + "",
            inspectionLotMark: this.batchNumForm.inspectionLotMark,
            extraId: this.batchNumForm.extraId,
          }).then((response) => {
            this.$modal.msgSuccess("操作成功!");
            this.getList();
            this.batchNumVidible = false;
          });
        })
        .catch(() => {});
    },
    handleApproval() {
      if (this.ids.length === 0) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      getAuditCheck({ id: this.ids[0] }).then((response) => {
        getAuditEcho({ id: this.ids[0] }).then((response) => {
          this.approvalModel = response.data;
          let auditCause = [];
          response.data.flawList.forEach((io) => {
            auditCause.push(io.minFlawName);
          });
          this.auditCause = auditCause.join(";");
        });

        this.approvalOpen = true;
      });
    },
    // 发起问题管理事件
    handleIssues() {
      if (this.ids.length !== 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      let params = this.selectRows[0];
      if (params.triggerQpms == 1)
        return this.$modal.msgWarning("这条数据已发起过问题管理");
      this.$modal
        .confirm(this.$t("issuesManagement.Confirmtoinitiateproblemmanagement"))
        .then(() => {
          console.log("跳转QPMS");
          window.history.pushState(
            { nyiqcIncoming: params },
            "",
            `/qpms/incomingMaterial/addMaintain?viewType=1&cb=1`
          );
        })
        .catch(() => {});
    },
    tableRowClassName({ row, rowIndex }) {
      if (row.isHighLight === true) {
        console.log("rowIndex", row);
        return "rowHighLight"; //若isHighLight为true，则使用“rowHighLight”样式
      } else {
        return "";
      }
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      // if (selection.length === 0) {
      //     return
      // }
      this.selectRows = selection;
      if (selection.length > 0) {
        this.rowifInspect = selection[0].ifInspect;
      }
      this.ids = selection.map((item) => item.id);
      console.log("this.ids", this.ids);
      this.incomingList.forEach((io, index) => {
        console.log("includes", this.ids.includes(io.id));
        if (this.ids.includes(io.id)) {
          io.isHighLight = true;
        } else {
          io.isHighLight = false;
        }
      });
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const dictId = row.dictId || this.ids;
      getType(dictId).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改字典类型";
      });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.open = false;
    },
    submitApproval: function () {
      this.approvalOpen = false;
      let submitData = {
        ...this.approvalModel,
        realityAuditName: this.name,
        realityAuditId: this.userId,
        id: this.ids[0],
      };
      if (this.approvalModel.auditResult === "0") {
        delete submitData.auditResult;
      }

      getAudit(submitData).then((response) => {
        this.$modal.msgSuccess("审核成功");
        this.getList();
      });
    },
    /** 发起检验提交 */
    submitAddForm(n) {
      // this.$modal.msgSuccess('发起成功!')
      // this.addInspection = false
      if (this.itemList.length == 0 || !this.itemList) {
        this.$message.error("请先获取检验项");
      } else {
        if (n == 1) {
          this.$refs.incomingSubmit1.submitAddForm();
        } else {
          this.$refs.incomingSubmit2.submitAddForm();
        }
      }
    },
    closevirtualMaterial() {
      this.virtualMaterialModel = {
        isVirtually: 1,
        associationOrder: "",
        materialName: "",
      };
      this.tempAssociationOrder = [""];
      this.itemList = [];
      this.batchAmountlist = [];
    },
    submitPrinter: function () {
      this.$modal.msgSuccess("打印成功!");
      this.printerOpen = false;
    },

    submitAuditClose: function () {
      this.reportAuditStatus = "";
      this.inspectionAndAuditOpen = false;
    },
    submitAuditCancel: function () {
      this.reportAuditStatus = "";
      this.inspectionAndAuditOpen = false;
    },
    submitAudit: function () {
      if (this.reportAuditStatus == "") {
        this.$modal.msgWarning(this.$t("请选择审核结果"));
        return;
      }
      // auditCheck(this.ids[0]).then((response) => {
      //   if (response.code === 200) {
      //     audit({
      //       id: this.ids[0],
      //       reportAuditId: this.userId,
      //       reportAuditName: this.name,
      //       reportAuditStatus: this.reportAuditStatus
      //     }).then((response) => {
      //       this.$modal.msgSuccess(response.msg)
      //       this.getList()
      //       this.reportAuditStatus = ''
      //       this.inspectionAndAuditOpen = false
      //     })
      //   } else {
      //     this.$modal.msgSuccess(response.msg)
      //     this.reportAuditStatus = ''
      //     this.inspectionAndAuditOpen = false
      //   }
      // })
      auditBatch({
        inspectionIds: this.ids,
        reportAuditStatus: this.reportAuditStatus,
      }).then((response) => {
        this.$modal.msgSuccess(response.msg);
        if (response.code == 200) {
          this.getList();
          this.reportAuditStatus = "";
          this.inspectionAndAuditOpen = false;
        } else {
          this.reportAuditStatus = "";
          this.inspectionAndAuditOpen = false;
        }
      });
    },

    /** 查看按钮操作 */
    handleView(scope) {
      this.$router.push({ path: "/incomingDetail/index/" + scope.row.id });
    },
    /** 打印预览操作 */
    handlePrinterView(scope) {
      getReport({ id: scope.row.id }).then((res) => {
        let reportId = res.data ? res.data : "791117854038990848";
        let a = document.createElement("a");
        a.href =
          process.env.VUE_APP_BASE_API +
          "/jimu/jmreport/view/" +
          reportId +
          "?token=" +
          getToken() +
          "&id=" +
          scope.row.id;
        a.target = "_blank";
        a.style.display = "none";
        document.body.appendChild(a);
        a.click();
        a.remove();
        // this.$router.push({
        //     path: '/incoming/printerPreview/' + scope.row.id,
        //     query: {
        //         usingDecision: scope.row.usingDecision,
        //     },
        // })
      });
    },
    /** 编辑按钮操作 */
    handleEdit(row) {
      this.drawer = true;
    },
    /** 关闭抽屉操作 */
    handleClose(row) {
      this.drawer = false;
    },
    /** 导出按钮操作 */
    handleExport() {
      let params = { ...this.queryParams };
      params.sheetStatus = params.sheetStatus.join(",");
      // params.maturity = params.maturity.join(',')
      if (params.inspectionTime && params.inspectionTime.length) {
        params.params.beginTime = params.inspectionTime[0];
        params.params.endTime = params.inspectionTime[1];
      } else {
        params.params.beginTime = "";
        params.params.endTime = "";
      }
      delete params.inspectionTime;
      if (params.checkoutEndTime && params.checkoutEndTime.length) {
        params.params.endBeginTime = params.checkoutEndTime[0];
        params.params.endEndTime = params.checkoutEndTime[1];
      } else {
        params.params.endBeginTime = "";
        params.params.endEndTime = "";
      }
      delete params.checkoutEndTime;
      this.download(
        "ny-iqc/incomingInspection/export",
        {
          ...params,
        },
        `type_${new Date().getTime()}.xlsx`
      );
    },
    handleExportTemplate() {
      if (this.ids.length !== 1) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      this.download(
        "ny-iqc/incomingInspection/exportById?id=" + this.ids[0],
        {},
        `type_${new Date().getTime()}.xlsx`
      );
    },
    handleExportDetail() {
      if (this.ids.length === 0) {
        this.$modal.msgWarning(this.$t("inspectionManagement.pleaseSelectOne"));
        return;
      }
      this.download(
        "ny-iqc/incomingInspection/exportDetails?ids=" + this.ids.join(","),
        {},
        `type_${new Date().getTime()}.xlsx`
      );
    },
    /** 刷新缓存按钮操作 */
    handleRefreshCache() {
      refreshCache().then(() => {
        this.$modal.msgSuccess("刷新成功");
      });
    },
    imgFileChange1(e) {
      let ids = e.map((item) => item.id);
      console.log("-------", ids);
      if (ids.length) {
        this.ncrModel.file1 = ids.join(",");
      }
    },
    imgFileChange2(e) {
      let ids = e.map((item) => item.id);
      if (ids.length) {
        this.ncrModel.file2 = ids.join(",");
      }
    },
    //download report in English
    handleENCOAExport(row) {
      this.download(
        "ny-iqc/incomingInspection/exportCoa",
        {
          type: 2,
          id: row.id,
        },
        `type_${new Date().getTime()}.xls`,
        "preview"
      )
        // 预览
        .then((res) => {
          var reader = new FileReader();
          let that = this;
          reader.onload = function () {
            console.log(reader.result);
            let workbook = XLSX.read(new Uint8Array(reader.result), {
              type: "array",
            });
            console.log(workbook);
            const worksheet = workbook.Sheets[workbook.SheetNames[0]];
            console.log(worksheet);
            that.excelHtml = XLSX.utils.sheet_to_html(worksheet);
            console.log(that.excelHtml);
            that.visibleXlsx = true;
            that.asyncFile = res;
          };
          reader.readAsArrayBuffer(res.blob);
        });
    },
    handleDialogCoa(row){
      this.coaRow = row
      this.selectCoaReportShow = true
    },
    handleSelectCoa(){
      this.$refs["selectCoaReportForm"].validate((valid) => {
        if (valid) {
          this.handleExportCoa(this.coaRow,{type:this.selectCoaReportForm.CoaReportType,fileType:this.selectCoaReportForm.CoaReportFile})
        }else{

        }
      })
    },
    // 下载COA报告
    handleExportCoa(row,query) {
      let params = { ...this.queryParams };
      params.sheetStatus = params.sheetStatus.join(",");
      // params.maturity = params.maturity.join(',')
      if (params.inspectionTime && params.inspectionTime.length) {
        params.params.beginTime = params.inspectionTime[0];
        params.params.endTime = params.inspectionTime[1];
      } else {
        params.params.beginTime = "";
        params.params.endTime = "";
      }
      delete params.inspectionTime;
      if (params.checkoutEndTime && params.checkoutEndTime.length) {
        params.params.endBeginTime = params.checkoutEndTime[0];
        params.params.endEndTime = params.checkoutEndTime[1];
      } else {
        params.params.endBeginTime = "";
        params.params.endEndTime = "";
      }
      delete params.checkoutEndTime;
      this.download(
        "ny-iqc/incomingInspection/exportCoa",
        {
          ...params,
          type: 1,
          ...query,
          id: row.id,
        },
        `type_${new Date().getTime()}.${query.fileType == 1 ? 'xls' : 'pdf'}`,
        "preview"
      )
        // 预览
        .then((res) => {
          if(query.fileType == 1){
            var reader = new FileReader();
            let that = this;
            reader.onload = function () {
              console.log(reader.result);
              let workbook = XLSX.read(new Uint8Array(reader.result), {
                type: "array",
              });
              console.log(workbook);
              const worksheet = workbook.Sheets[workbook.SheetNames[0]];
              console.log(worksheet);
              that.excelHtml = XLSX.utils.sheet_to_html(worksheet);
              console.log(that.excelHtml);
              that.visibleXlsx = true;
              that.asyncFile = res;
            };
            reader.readAsArrayBuffer(res.blob);
          }else{
            this.asyncFile = res;
            this.pdfUrl = window.URL.createObjectURL(res.blob);
            this.visiblePdf = true
          }
        });
    },

    //
    //raise a produce trail logic
    checkIsStockPending(row) {
      return row.sheetStatus == "7"; //待过账
    },
    checkCanRaiseTrail() {
      if (this.selectRows.length == 0) {
        return false;
      }
      for (let i = 0; i < this.selectRows.length; i++) {
        const row = this.selectRows[i];
        //qualified and stock pending
        if (row.decideResult != "1" || !this.checkIsStockPending(row)) {
          return false;
        }
      }
      return true;
    },
    //raise a produce trail
    raiseProduceTrial() {
      if (this.ids.length === 0) {
        this.$modal.msgWarning(this.$t("trialinvestment.noSelectedWarning"));
        return;
      }
      if (!this.checkCanRaiseTrail()) {
        this.$modal.msgWarning(this.$t("trialinvestment.selectTips"));
        return;
      }
      this.$modal
        .confirm(this.$t("trialinvestment.confirmRasieTrail"))
        .then(() => {
          raiseProduceTrail({
            ids: this.ids,
          }).then((res) => {
            console.log("raise producing trials", res);
            if (res.code == 200) {
              this.$modal.msgSuccess(this.$t("发起试投成功！"));
            } else {
              this.$modal.msgError(res.msg);
            }
          });
        });
    },
    //end raise produce trial logic
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-card {
  padding-top: 20px;
  border: 0px;
  box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  padding-bottom: 20px;
}

::v-deep .el-aside {
  padding: 0;
  margin-bottom: 0;
}

.content-style {
  border: 0px;
  box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.08);
  border-radius: 2px;
  background-color: white;
  margin-top: 10px;
}

::v-deep .el-button-group .selBtn {
  background: #fff;
  border: 1px solid #0b7be3;
  color: #0b7be3;
}

::v-deep .el-button-group .unselBtn {
  background: #fff;
  border: 1px solid #ededf2;
  color: #666666;
}

.header-left {
  float: left;
  font-size: 14px;
  font-family: PingFangSC-Semibold, PingFang SC;
  font-weight: 600;
  color: #333333;
  line-height: 30px;
  display: flex;
  justify-content: center;
  border-bottom: 2px solid #0b7be3;
}

.header-right {
  float: right;
}

.container-header {
  float: left;
  width: 100%;
  border-bottom: 1px solid #ededf2;
  display: flex;
  align-items: center;
}

.container-table {
  float: left;
  margin-top: 6px;
  width: 100%;
}

.mb8 {
  float: left;
  margin-top: 6px;
  width: 100%;
}

::v-deep .el-form-item {
  margin-bottom: 5px;
}

.drawer-footer {
  display: flex;
  position: relative;
  z-index: 9999;
  bottom: -40px;
  height: 40px;
  justify-content: center;
  width: 100%;
}

.drawer-close {
  background: #f7f8fa;
  border-color: #f7f8fa;
}

::v-deep .form-input .el-form-item__content {
  width: 185px;
}

::v-deep .el-dialog--center .el-dialog__body {
  padding: 15px 30px;
}

.smallRadio {
  ::v-deep .el-radio__label {
    font-size: 12px;
  }
}

.greenTag {
  position: relative;
  left: 5px;
  padding-left: 10px;
}

.redTag {
  position: relative;
  left: 5px;
  padding-left: 10px;
}

.yellowTag {
  position: relative;
  left: 5px;
  padding-left: 10px;
}

::v-deep .table-fixed {
  .el-table__fixed-right {
    height: 98.5% !important;
    background: #fff;
  }

  .el-table__fixed {
    height: 98.5% !important;
    background: #fff;
  }
}
::v-deep .el-table .el-table__header-wrapper .el-table__cell,
::v-deep
  .el-table
  .el-table__fixed
  .el-table__fixed-header-wrapper
  .el-table__cell {
  height: 70px;
}
::v-deep .el-table__header-wrapper {
  height: 70px;
}
::v-deep .rowHighLight {
  background: oldlace;
}

::v-deep .el-dialog__body {
  max-height: 500px;
  overflow-y: auto;
}

.form .el-col {
  margin-bottom: 10px;
}
.exportitemBtn{
  margin-top: 8px;
}
</style>
